Read more about the article FOSSASIA Summit 2017 Wrap Up
Too big Crowd for only One Photo / One of Many Group Photos by Michael Cannon

FOSSASIA Summit 2017 Wrap Up

The FOSSASIA Summit 2017 was an unforgettable event thanks to everyone who helped to make it possible! We would like to thank our co-organiser the Science Centre Singapore and all sponsors, supporters, speakers and volunteers. Below are interesting numbers and facts of 2017 and information on highlights of the event.

FOSSASIA Summit 2017 Numbers & Facts

  • 3,145 people attended the event over 3 days including 229 speakers and 60 volunteers.
  • 41 nationalities participated in the summit: 70.8% from Singapore, followed by India, Indonesia, Germany, China, Japan, Vietnam and many others
  • There were 23.6% female attendees.
  • 60% of attendees were IT professionals.
  • 5 keynotes, 231 scheduled sessions, 22 lightning talks, and over 30 projects and companies presented their work in the exhibition.
  • Talks are already available as videos. Hundreds of photos have been uploaded to social networks. 2000+ tweets [tw] with the FOSSASIA hashtag were posted during the event.

FOSSASIA Summit 2017 Highlights

The three-day program with nearly 20 parallel tracks made FOSSASIA Summit the biggest open tech event in the region. One very interesting fact was the entire conference was fully managed by FOSSASIA built open source event management system, EventYay. All the technical setting was also done in-house by the FOSSASIA Team. In the effort of making the event the best experience for visitors, FOSSASIA team organized a series of extracurricular activities including pre-event meet&greet, pub crawl, culture walk, social event, see you again cocktails, and a lucky draw.

Day 1 Opening Day with Keynotes

Chan Cheow Hoe, GovTech’s Chief Information Officer, emphasized how the Singapore Government’s central information technology systems and infrastructure drive the development and delivery of innovative public services for citizens and businesses.

Chan Cheow Hoe, GovTech’s CIO, photo by Nguyen Thi Tra My

Follow-up by an interesting story by Øyvind Roti who currently leads Google’s international team of Cloud Architects. He spoke about how to get involved and contribute to the Google Cloud Open Source products and related projects, including machine learning, systems, client-side libraries and data analytics tools.

Øyvind Roti, photo by Gabriel Lee

Andrey Terekhov brought Microsoft into the Open Source picture with some insights that many were not aware of. MS actually are the top contributors to Github and they are hosting many Open Source projects themselves. Andrey explained in details Microsoft’s open source strategy and developing business in Asia Pacific region, with a particular focus on scaling up open source workloads on Microsoft Azure cloud platform.

Andrey Terekhov, Open Source Sales & Marketing Lead at Microsoft, photo by Kai En Mui

The final keynote of the day was conducted by a German privacy activist – Frank Karlitschek the founder of ownCloud and later Nextcloud, an open source and fully federated and distributed network for files and communication. As the topic of the privacy and personal data on the internet are under attack by hackers and international espionage programs, Frank shared with the audience how the Internet can be used as a free and democratic medium again. 

Open Source AI Topics 

The highlight of the day was the introduction of SUSI AIFOSSAISA’s Open Source Personal Assistant. Michael Christen, founder and also core developer talked about SUSI’s current development stage as well as project’s ambition and the plan for the future. He demonstrated some amazing things you can do with SUSI such as searching for locations, finding translations in over 100 languages, asking SUSI travel information, weather etc. One of the exciting features is the auto-improvement ability: the more you interact with SUSI, the better and accurate its answers become. Michael also showed the audience how they can actually contribute and create the largest corpus of knowledge for SUSI AI Assistant.

Michael Christen about SUSI AI, OpenAI and the role of Elon Musk, photo by Michael Cannon

Liling Tan, a data scientist from Rakuten, spoke about Natural Language Processing (NLP) which is the task of the computationally understanding and production of human languages, often using a mix of hand-crafted rules and machine learning techniques. Konrad Willi Döring brought AI to next level when he presented the Brainduino Project including a brief introduction to EEG-based brain-computer interfaces as well as a look into the future of BCI technology.

Konrad Willi Döring Brainduino Project, photo by Michael Cannon

FOSSASIA’s favorite speaker, Andrew “bunnie” Huang, came back with “Let’s Make Technology more Inclusive”. Bunnie and his team examined some of the cultural and technological barriers that have stymied inclusiveness, using gender imbalance as a case study. They later on, proposed a solution called “Love to Code”, which attempts to address the issue of inclusiveness in technology. 

The day finished with a panel discussion on The Future of AI with a diverse group of  five panelists: Andrew Selle (Google Brain Team, US), Steffen Braun (KI Group), Michael Christen (SUSI AI), Harish Pillay (Internet Society), Bunnie Huang (Chibitronics PTE LTD)

It was a very interactive session between speakers and attendees, discussing the possibilities and implications of AI.

AI Panel, photo by Michael Cannon

CodeHeat Award Ceremony

From September 2016 to February 2017, FOSSASIA held a CodeHeat contest to encourage more developers to get involved and contribute to the FOSSASIA open source projects, namely Open Events Orga Server, AskSUSI project, and LokLak. 442 developers had joined the contest, over a thousand pull requests were made during over this 6 months period of CodeHeat. Three winners and two finalists from the top 10 contributors who have contributed awesome code were chosen to fly to Singapore for the FOSSASIA Summit 2017 to share what they’ve done, and meet the open source community gathered here.

CodeHeat Award Ceremony, photo by Michael Cannon

PubCrawl

A get-together at Pubcrawl has become a tradition of every FOSSASIA Summit. At the end of the first day,  speakers and participants met at Chinatown and started a fun evening strolling around various pubs, tasting local beverages and specialties. The hang-out has always been a great opportunity for speakers to carry on their unfinished conversations during the day as well as to enhance the friendship among visitors and residents.

Pub Crawl, photo by Ben Sadeghi
Andrew “bunnie” Huang, Brady Forrest and Sean “Xobs” Cross at the Pub Crawl, photo by Ben Sadeghi

Day 2 Extensive Day of Workshops and Presentations  

FOSSASIA Summit Day 2 is always the busiest day with an extensive program starting from 9 am until 6:30 pm. Dedicated tracks included Startup and Business Development – Database PGDay – Open Tech Google Track – Python – Hardware & Making DevOps  – Security and Privacy – Science – Android – Debian Mini-Debconf – Tech Kids – Open Source Software – Health Tech – Web & Mobile – Kernel & Platform – AI & Machine Learning

Open Tech – Google Open Source Track

Stephanie Taylor, the Program Manager at Google Open Source Outreach team gave an educational talk about Google Code-in program as an early opening of the Google’s Open Tech Track. This introduction was favored by local students as well as young international developers. In the following topic about Future of the Web, Anuvrat Rao introduced the latest open technology to address critical user needs on the open web.

Stephanie Taylor and GCI 2016 Students

Andrew Selle from Google Brain Team carried on the session with an overview of the open source software library TensorFlow and discussed how the open source community has shaped its development and success. Devan Mitchem introduced The Chromebook, a new, faster computer that offers thousands of apps. He also showed the audience how to integrate and experience Android apps on this machine for greater productivity and flexibility. Denis Nek wrapped up Google’s Tracks by a talk about Model–view–viewmodel (MVVM), a software architectural pattern. In this last topic, he explained why and how he could solve many common problems of android developers using this approach.

Tech Kids Track

Followed up the success of 2016’s summit, FOSSASIA 2017 extended Tech Kids Track throughout its 3-day event. Many parents brought their kids along to attend the talks and workshops. Most importantly, these young attendees showed their great interest in Open Technology. The kids’ voluntary participation in the tracks completed the aim of FOSSASIA in fostering education at a young age. With the power of open knowledge, we believe the bright future of world leaders start from today’s education.

Elda Webb and Creativity workshop, photo by Ka Ho Ying

Kids workshops covered topics such as Git for beginners, software translation with WebLate, PyGame 101 Codelab, how to developer your first mobile app, make a DIY paper spectrometer, create a promotion video with open source tools etc.

Kids and guardians learn how to work with Git, photo by Ka Ho Ying

Science Track – Mission Mars 

This fun and educational workshop was organized by Microsoft Open Source Team.  In this rescue mission, attendees learned to create a bot using an open source framework and tools. They were given access to MS code repositories and other technical resources. Workshop participants had to complete 3 missions and 2 code challenges in order to bring the Mars mission back on track. It was pretty challenging but at the same time super exciting.

Mission Mars’ Winner and Mentors

Python Track

Python Track has always attracted good audience’s response since 2015. In this year summit, the track covered very informative topics ranging from metaclasses in Python 2 and 3, computing using Cython to Go-lang (a new open source programming language), Pygame 101, the effective use of python in Science and Maths with live demos of successful experiments etc. 

PyGame 101 Codelab Workshop

A 2-hour workshop was conducted by Kushal Das giving the audience the overview of MicroPython, how to update NodeMCU devices with MicroPython firmware and using sensors with NodeMCU for their first IoT device.

MicroPython workshop using NodeMCU
Python Mentors, photo by Ka Ho Ying

Database Track – PostgreSQL Day

This was the second year FOSSASIA hosted PGDay. We were delighted to welcome amazing speakers like Dr. Michael Meskes (founder and CEO of credativ Group), Maksym Boguk (co-founder of PostgreSQL consulting), and many other  PostgreSQL developers and consultants across the globe.

It was very interesting to learn how an open source database, PostgreSQL, has rapidly extended its application into the enterprise sector, one of the examples was how PostGIS is being by agricultural producer in Australia.

PGDay at FOSSASIA Summit 2017

Day 3 More sessions and the final keynote by Daimler’s Representatives 

Day 3 Dedicated Tracks consisted of Hardware & Making – Tech Kids – Science – Android – Blockchain – Open Tech – AI & Machine Learning – Internet, Society & Politics – Web & Mobile – Security and Privacy – DevOps – Database MySQL Day – Design, Art, Community – Open Source Software.

It was wonderful to have two special guests from Daimler headquarter in Stuttgart – Jan Michael Graef (CFO of CASE) and Vlado Koljibabic (leads IT for the new CASE business and COO of the Digital and IT organization). The presence of Daimler, a traditional corporate business in the open source world was not only well received by the audience but also triggered an excitement and the curiosity of the crowd: What is the background of the growing involvement and support of Open Source by Daimler?

Daimler in the house: Danial, Vlado, Hong Phuc, Jan and Mario, photo by Michael Cannon

Daimler AG is known for one of the world’s most successful automotive companies. With its Mercedes-Benz Cars, Daimler Trucks, Mercedes-Benz Vans, Daimler Buses, and Daimler Financial Services divisions. The Group is one of the leading global suppliers of premium cars and is the world’s largest manufacturer of commercial vehicles. At FOSSASIA Summit 2017, Jan and Vlado made an introduction to CASE – these letters will shape the future of Mercedes-Benz Cars. They stand for the strategic pillars of connectivity (Connected), autonomous driving (Autonomous), flexible use (Shared & Services) and electric drive systems (Electric), which will be intelligently combined with one another by the company.

Jan Michael Graef and Vlado Koljibabic from Daimler, photo by Ka Ho Ying

In their talk Vlado and Jan outlined how Daimler recognizes the power of Open Source development and we had the chance to get insights into some very exciting ideas how Daimler is planning to shape the logistics sector with services based on Open Source technologies. The company is even considering cryptocurrency payments for services in the future and is already working on using Blockchain technologies for its automobile services for logistics companies.

Daimler is looking for outstanding developers to build some very exciting solutions based on Open Source around cars and much more. Please check out Daimler’s job opportunities here.

Web & Mobile Track – featured OpenEvent (EventYay) System

Finally, there is an Open Source event management system said Mario Behling, founder of open-event (eventyay) and the summit’s co-organiser. During the last two years, the FOSSASIA team has been working on a complete functional open source solution for event organisers. More than 5,000 commits have been made from more than 100 developers worldwide. The hosted solution of the application is available at EventYay.com and ready to be tested as an Alpha product.

The system enables organizers to manage events from concerts to conferences and meet-ups. It offers features for events with several tracks and venues. Event managers can create invitation forms for speakers, build schedules in a drag and drop interface, implement ticketing system and much more. The event information is stored in a database. The system also provides API endpoints to fetch the data, and to modify and update it. Organizers can import and export event data in a standard compressed file format that includes the event data in JSON and binary media files like images and audio.

OpenEvent Scheduler – Drag & Drop interface

The Open-event core team of 7 senior developers came together at the FOSSASIA summit to showcase the latest development, make live demos, conduct deployment workshops and discuss future applications.

Featured Open Event presentations and workshops:

    • Better Events with Open Event | Mario Behling
    • Deploy Open Event Organizer Server | Saptak Sengupta
    • Scaling Open Event Server with Kubernetes | Niranjan Rajendran
    • Open Event API | Avi Aryan
    • Open Event Web App | Aayush Arora
    • An Introduction to the Open Event Android Project and it’s capabilities| Manan Wason
    • Agile Workflow and Best Practices in the Open Event Android App Generator Project | Harshit Dwivedi

Database Track – MySQL Day

This year FOSSASIA proudly hosted MySQL Day within the database track.  12 senior developers/speakers from Oracle around the world got together at the summit. 14 scheduled talks and workshop were conducted. Beginning with Sanjay Manwani, MySQL Director from India, he talked about ‘the State of the Dolphin’, sharing an overview of the recent changes in MySQL and the direction for MySQL 8 as well as an introduction to Oracle cloud. The day continued with selective topics from MySQL optimizer features to in-depth workshops such as MySQL operations in Docker – workshop or MySQL Performance Tuning.

MySQL Team, photo by Mayank Prasad

Additionally, Ricky Setyawan organized an unconference session or a MySQL Community Meetup Space where he invited the community members to meet and to start a direct conversation with MySQL’s developers. 

See you again Cock-Tails 

After the closing session, FOSSASIA attendees were invited by Daimler to join an after-event cocktail party. People were happy for the chance to finish up their discussions while enjoying the nice view of the city from a spacious balcony with finger food, drinks and good music from the local band.  

Engineers.SG Team, photo by Ka Ho Ying
Photo by Nguyen Thi Tra My
FOSSASIA regular friends Felix Dahmen, Joerg Henning & Emin Aksehirli, photo by Guness
Music performance by a local band

Exhibition and Networking Space at FOSSASIA Summit

The biggest goal of the FOSSASIA Summit is to bring people across borders together at a physical space where they can freely share, showcase, discuss and collaborate on existing projects or new ideas. We are happy to see many open source communities across Asia at this year’s gathering. What could be better than a face-to-face discussion over coffee with people who shared the same vision and belief: ‘With open technologies, we can make the world a better place’

Google Cloud Team at FOSSASIA
Dietrich Ayala from Mozilla sharing details about A-frame with attendees
Open Hardware corner with Dan and Kiwi, FOSSASIA organizers
Sindhu Chengad explained Open Source at Microsoft
OpenSUSE Booth
Michael Meskes (right) and Engineer from Credativ Germany
Matthew Snell from xltech.io, Singapore
MySQL Team, photo by Michael Cannon
Thomas Kuiper from gandi.net, Taiwan, photo by Michael Cannon
Men gathering at Pyladies Pune table
Wan Leung Wong from TinyBoy 3D printer project, Hongkong
Fresh coffee in the house

FOSSASIA What’s Next?

Mark your calendar for the next FOSSASIA Summit, which will take place in March 2018. We are looking forward to seeing you again in Singapore. If you are meetup organizers, community leaders, we would like to invite you to host a track at the next FOSSASIA Summit, please write to us about your experience and contribution in the open source world via office@fossasia.org

As always thanks to Michael Cheng and Engineers.SG team for all the videos, thanks to our photographers Michael Cannon, Ka Ho Ying and the team for capturing some of the very best moment of us. You can search for more photos by typing #fossasia on loklak (or alternatively on Twitter) or Flickr. If you also want to share photos you took during the summit, please add them to the group pool.

Another Group Photo by Michael Cannon

Blog Posts by Attendees

Throwback to FOSS Asia 2017, Michael Meske Credativ

FOSSASIA – A wonderful Experience, Pooja Yadav

Speaking at FOSSASIA 2017, Santosh Viswanatham

Team Reactives at FOSSASIA!, Rails Girls, Shwetha from Team Reactives

Ten ways in which FOSSASIA ’17 helped me grow, Nisha Yadav

FOSSASIA 2017, Edwin Zakaria

Canaan at FOSSASIA 2017: Blockchain Software for Hardware

Speaking at FOSSASIA’17 | Seasons of Debian : Summer of Code & Winter of Outreachy, urvikagola

FOSSASIA Summit Singapore and Codeheat, Rishi Raj

FOSSASIA with SE Linux, Jason Zaman

Lessons from {distributed,remote,virtual} communities and companies, Colin Charles

Get ready for FOSSASIA Summit 2017!, Andrey Terekhov

In The Heat of Code : A Mentor’s POV, Saptak Sengupta

Links

FOSSASIA Summit 2017 Photos: https://www.flickr.com/groups/fossasia-2017-singapore/pool

FOSSASIA Summit 2017 Feedback form: tell us how we can make it better for you

FOSSASIA Videos: https://www.youtube.com/fossasiaorg

FOSSASIA Projects: http://labs.fossasia.org

FOSSASIA Repositories: https://github.com/fossasia

FOSSASIA on Twitter: https://twitter.com/fossasia

FOSSASIA on Facebook: https://www.facebook.com/fossasia

FOSSASIA SG Meetup: http://www.meetup.com/FOSSASIA

Continue ReadingFOSSASIA Summit 2017 Wrap Up
Read more about the article Apply for Your Free Stay during the FOSSASIA Summit 2017 with our 100 #OpenTechNights Program
FOSSASIA OpenTechSummit 2016. http://2016.fossasia.org/

Apply for Your Free Stay during the FOSSASIA Summit 2017 with our 100 #OpenTechNights Program

The FOSSASIA Summit 2017 takes place from Friday March 17 – Sunday March 19 at the Science Centre Singapore. We are now inviting Open Source contributors to apply for a free stay in a Singapore hostel and a free ticket to the event. All you have to do is convince us, that you are an awesome Open Source contributor!

The details

Developers from all over the world are joining the FOSSASIA Summit. We want to connect established and new Open Tech contributors alike. Therefore FOSSASIA is supporting the Open Source community to join the event by offering 100 free nights stay at a hostel in the centre of Singapore and a free ticket to the event. All you have to do is to fill in the form with information that convinces us that you are an awesome contributor in the Open Source community.

The Process

Step 1: Please fill in our form here before February 17 (23:00 Singapore Time).

Step 2: We will get back to you at latest within 3 days after the deadline if you are selected. But, also we are choosing very convincing applicants on an ongoing basis. So, the earlier you apply the higher your chances to get a free stay might be.

Step 3: The selected applicants will need to confirm their itinerary and tickets before March 1st to re-assure their free stay in Singapore.

Expectations of Participants – Share what you learn

1. Please support volunteers, speakers and participants at the event. Let’s bring all this good spirit of sharing Open Technologies and learning together!

2. Help to reach out to participants who cannot join us at the event. For example make some tweets, share what you learn on social media, publish photos and put up blog posts about the summit.

Our Team

Our team of “100 #OpenTechNights” – Hong Phuc Dang, Mario Behling, and Roland Turner – is excited to meet you in Singapore!

Apply Now

Apply for a free stay with #FOSSASIA #OpenTechNights and participation at the FOSSASIA Summit 2017 now here!

More Information

More updates, tickets and information on speakers also on our #OpenEvent system: https://eventyay.com/e/45da88b7/

Continue ReadingApply for Your Free Stay during the FOSSASIA Summit 2017 with our 100 #OpenTechNights Program

Generating xCal calendar in python

{ Repost from my personal blog @ https://blog.codezero.xyz/generate-xcal-calendar-in-python }

“xCal”, is an XML format for iCalendar data.

The iCalendar data format (RFC5545) is a widely deployed interchange format for calendaring and scheduling data.

A Sample xCal document

<?xml version="1.0" encoding="utf-8"?>  
<iCalendar xmlns:xCal="urn:ietf:params:xml:ns:xcal">  
    <vcalendar>
        <version>2.0</version>
        <prodid>-//Pentabarf//Schedule 1.0//EN</prodid>
        <x-wr-caldesc>FOSDEM 2016</x-wr-caldesc>
        <x-wr-calname>Schedule for events at FOSDEM 2016</x-wr-calname>
        <vevent>
            <method>PUBLISH</method>
            <uid>123e4567-e89b-12d3-a456-426655440000</uid>
            <dtstart>20160131T090000</dtstart>
            <dtend>20160131T091000</dtend>
            <duration>00:10:00:00</duration>
            <summary>Introduction to the SDR Track- Speakers, Topics, Algorithm</summary>
            <description>&lt;p&gt;The opening talk for the SDR devroom at FOSDEM 2016.&lt;/p&gt;</description>
            <class>PUBLIC</class>
            <status>CONFIRMED</status>
            <categories>Software Defined Radio</categories>
            <url>https:/fosdem.org/2016/schedule/event/sdrintro/</url>
            <location>AW1.125</location>
            <attendee>Martin Braun</attendee>
        </vevent>
    </vcalendar>
</iCalendar>

Each event/session will be in a seperate vevent block. Each speaker/attendee of an event/session will be in an attendee block inside a vevent block.

Some important elements are:

  1. version – Has the version of the iCalendar data
  2. prodid – Contains the name of the application/generator that generated this document
  3. x-wr-caldesc – A descriptive name for this calendar
  4. x-wr-calname – A description of the calendar

The structure and keywords used in xCal are the same as those used in the iCal format. To generate the XML document, we’ll be using python’s ElementTreeXML API that is part of the Python standard library.

We’ll be using two main classes of the ElementTree API:

  1. Element – used to create a standard node. (Used for the root node)
  2. SubElement – used to create a sub element and attache the new node to a parent

Let’s start with the root iCalendar node and set the required attributes.

from xml.etree.ElementTree import Element, SubElement, tostring

i_calendar_node = Element('iCalendar')  
i_calendar_node.set('xmlns:xCal', 'urn:ietf:params:xml:ns:xcal')

Now, to add the vcalendar node to the iCalendar node.

v_calendar_node = SubElement(i_calendar_node, 'vcalendar')

Let’s add the other aspects of the calendar to the vcalendar node as separate sub nodes.

version_node = SubElement(v_calendar_node, 'version')  
version_node.text = '2.0'

prod_id_node = SubElement(v_calendar_node, 'prodid')  
prod_id_node.text = '-//fossasia//open-event//EN'

cal_desc_node = SubElement(v_calendar_node, 'x-wr-caldesc')  
cal_desc_node.text = "Calendar"

cal_name_node = SubElement(v_calendar_node, 'x-wr-calname')  
cal_name_node.text = "Schedule for sessions"

Now, we have added information about our calendar. Now to add the actual events to the calendar. Each event would be a vevent node, a child of vcalendar node. We can loop through all our available event/sessions and add them to the calendar.

for session in sessions:  
    v_event_node = SubElement(v_calendar_node, 'vevent')

    uid_node = SubElement(v_event_node, 'uid')
    uid_node.text = str(session.id)

    dtstart_node = SubElement(v_event_node, 'dtstart')
    dtstart_node.text = session.start_time.isoformat()

    dtend_node = SubElement(v_event_node, 'dtend')
    dtend_node.text = tz.localize(session.end_time).isoformat()

    duration_node = SubElement(v_event_node, 'duration')
    duration_node.text =  "00:30"

    summary_node = SubElement(v_event_node, 'summary')
    summary_node.text = session.title

    description_node = SubElement(v_event_node, 'description')
    description_node.text = session.short_abstract

    class_node = SubElement(v_event_node, 'class')
    class_node.text = 'PUBLIC'

    status_node = SubElement(v_event_node, 'status')
    status_node.text = 'CONFIRMED'

    categories_node = SubElement(v_event_node, 'categories')
    categories_node.text = session.session_type.name

    url_node = SubElement(v_event_node, 'url')
    url_node.text = "https://some.conf/event/" + str(session.id)

    location_node = SubElement(v_event_node, 'location')
    location_node.text = session.microlocation.name

    for speaker in session.speakers:
        attendee_node = SubElement(v_event_node, 'attendee')
        attendee_node.text = speaker.name

Please note that all the timings in the XML Document must comply with ISO 8601 and must have the date+time+timezone. Example: 2007-04-05T12:30-02:00.

We’re still not done yet. We now have the XML document as an Element object. But we’ll be needing it as a string to either store it somewhere or display it.

The document can be converted to a string by using the ElementTree API’s tostring helper method and passing the root node.

xml_as_string = tostring(i_calendar_node)

And that’s it. You now have a proper XML document representing your events.

Continue ReadingGenerating xCal calendar in python

Adding swap space to your DigitalOcean droplet, if you run out of RAM

The Open Event Android App generator runs on a DigitalOcean. The deployment runs on a USD 10 box, that has 1 GB of RAM, but for testing I often use a USD 5 box, that has only 512mb of RAM.

When trying to build an android app using gradle and Java 8, there could be an issue where you run out of RAM (especially if it’s 512 only).

What we can do to remedy this problem is creating a swapfile. On an SSD based system, Swap spaces work almost as fast as RAM, because SSDs have very high R/W speeds.

Check hard disk space availability using

df -h

There should be an output like this

Filesystem      Size  Used Avail Use% Mounted on
udev            238M     0  238M   0% /dev
tmpfs            49M  624K   49M   2% /run
/dev/vda1        20G  1.1G   18G   6% /
tmpfs           245M     0  245M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           245M     0  245M   0% /sys/fs/cgroup
tmpfs            49M     0   49M   0% /run/user/1001

The steps to create a swap file and allocating it as swap are

sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

We can verify using

sudo swapon --show
NAME      TYPE  SIZE USED PRIO
/swapfile file 1024M   0B   -1

And now if we see RAM usage using free -h , we’ll see

              total        used        free      shared  buff/cache   available
Mem:           488M         37M         96M        652K        354M        425M
Swap:          1.0G          0B        1.0G

Do not use this as a permanent measure for any SSD based filesystem. It can corrupt your SSD if used as swap for long. We use this only for short periods of time to help us build android apks on low ram systems.

Continue ReadingAdding swap space to your DigitalOcean droplet, if you run out of RAM

Doing a table join in Android without using rawQuery

The Open Event Android App, downloads data from the API (about events, sessions speakers etc), and saves them locally in an SQLite database, so that the app can work even without internet connection.

Since there are multiple entities like Sessions, Speakers, Events etc, and each Session has ids of speakers, and id of it’s venue etc, we often need to use JOIN queries to join data from two tables.

 

Android has some really nice SQLite helper classes and methods. And the ones I like the most are the SQLiteDatabase.query, SQLiteDatabase.update, SQLiteDatabase.insert ones, because they take away quite a bit of pain for typing out SQL commands by hand.

But unfortunately, if you have to use a JOIN, then usually you have to go and use the SQLiteDatabase.rawQuery method and end up having to type your commands by hand.

But but but, if the two tables you are joining do not have any common column names (actually it is good design to have them so – by having all column names prefixed by tablename_ maybe), then you can hack the usual SQLiteDatabase.query() method to get a JOINed query.

Now ideally, to get the Session where speaker_id was 1, a nice looking SQL query should be like this –

SELECT * FROM speaker INNER JOIN session
ON speaker_id = session_speaker_id
WHERE speaker_id = 1

Which, in android, can be done like this –

String rawQuery = "SELECT * FROM " + SpeakerTable.TABLE_NAME + " INNER JOIN " + SessionTable.TABLE_NAME
        + " ON " + SessionTable.EXP_ID + " = " + SpeakerTable.ID
        + " WHERE " + SessionTable.ID + " = " +  id;
Cursor c = db.rawQuery(
        rawQuery,
        null
);

But of course, because of SQLite’s backward compatible support of the primitive way of querying, we turn that command into

SELECT *
FROM session, speaker
WHERE speaker_id = session_speaker_id AND speaker_id = 1

Now this we can write by hacking the terminology used by the #query() method –

Cursor c = db.query(
        SessionTable.TABLE_NAME + " , " + SpeakerTable.TABLE_NAME,
        Utils.concat(SessionTable.PROJECTION, SpeakerTable.PROJECTION),
        SessionTable.EXP_ID + " = " + SpeakerTable.ID + " AND " + SpeakerTable.ID + " = " +  id,
        null,
        null,
        null,
        null
);

To explain a bit, the first argument String tableName can take table1, table2 as well safely, The second argument takes a String array of column names, I concatenated the two projections of the two classes. and finally, put by WHERE clause into the String selection argument.

You can see the code for all database operations in the android app here  https://github.com/fossasia/open-event-android/blob/master/android/app/src/main/java/org/fossasia/openevent/dbutils/DatabaseOperations.java

Continue ReadingDoing a table join in Android without using rawQuery

Keep your node server running using PM2

The open event webapp generator is a node projects (using an express server), and a copy of it runs all the time on my personal DigitalOcean box (other than our heroku instance).

On a service like Heroku, the platform manages the task of bringing your server process up. But on, say a Linux distro on the DO box, you have to manually do

 npm run server

to be able to run the server.

While that is all good, it is a foreground shell process, which means, you will lose the node server, when you log out (or your internet connection into the ssh breaks).
So we need to be able to keep the process running in the background.

The way we do it in bash on Unix, is that we can do either of the following

 npm run server&

The “&” at the end means it will make a background fork of this task. Or if you’ve already started it without it, you can also do the following.

npm run server # starts in foreground
#Press Ctrl + Z, this pauses task and frees the shell
bg 1 # sends task no 1 to background thread.

Again, both these are hacky methods, will work only on Unix OSs, and are not really recommended for production.
For production, we need a Process Manager, for Node.js the best we can get is pm2 – purpose built process manager for node.

Install pm2 first

sudo npm install -g pm2

Using pm2, we can start any process that can be started with node. We can start the app.js script like this

pm2 start src/app.js

Also, pm2 can run npm tasks too like

pm2 start npm -- start

Pm2 has a pretty status message display window. And we can start, stop, pause, kill and/or restart any process.

 

Screenshot from 2016-08-28 01-19-29

Continue ReadingKeep your node server running using PM2

Using Partial in Handlebars and Reusing Code

Open Event Webapp uses handlebar partials for optimizing code. We can reuse a template using Handlebars partial.

How to use Handlebars partial ?

To use Handlebars partial, we have to follow some easy steps:

Step 1: In the .hbs file containing code, register your partial by using function Handlebars.registerPartial 

Handlebars.registerPartial('myPartial', '{{name}}')

Step 2: Calling the partial

{{> myPartial }}

In Open-Event Webapp we have made partials for common templates like navbar and footer.

1. // Navbar template (navbar.hbs)

  
 <!-- Fixed navbar -->
 <nav class="navbar navbar-default navbar-fixed-top">
  <div class="container">
   <div class="navbar-header navbar-left pull-left">
    <a class="navbar-brand" href="{{ eventurls.main_page_url }}">
    {{#if eventurls.logo_url}}
    <img alt="{{eventurls.name}}" class="logo logo-dark" src="{{  eventurls.logo_url }}">
    {{else}}
    {{ eventurls.name }}
    {{/if}}
    </a>
   </div>
 <div class="navbar-header navbar-right pull-right">
   <ul style="margin-left:20px" class="nav navbar-nav pull-left">
   {{#sociallinks}}
   {{#if show}}
    <li class="pull-left"><a href="{{link}}" style="padding-right:0; padding-left:0;margin-left:15px"><i class="fa fa-lg fa-{{icon}}" aria-hidden="true" title="{{{icon}}}"></i></a></li>
   {{/if}}
   {{/sociallinks}}
   </ul>
 <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse" style="margin-left:1em;margin-top:1em;">
   <span class="sr-only">Toggle navigation</span>
   <span class="icon-bar"></span>
   <span class="icon-bar"></span>
   <span class="icon-bar"></span>
 </button>
 </div>

 <div class="hidden-lg hidden-md hidden-sm clearfix"></div>
   <div class="collapse navbar-collapse">
    <ul class="nav navbar-nav navbar-right">
     <li class="navlink"><a id="homelink" href="index.html">Home</a>
     {{#if timeList}}
     <li class="navlink">
     <a id="schedulelink"href="schedule.html">
     Schedule</a>
     </li>
     {{/if}}
     {{#if tracks}}
     <li class="navlink">
      <a id="trackslink" href="tracks.html">Tracks</a>
    </li>
  {{/if}}
     {{#if roomsinfo}}
     <li class="navlink">
      <a id="roomslink" href="rooms.html">Rooms</a>   
     </li>
    {{/if}}
    {{#if speakerslist}}
    <li class="navlink">
      <a id="speakerslink" href="speakers.html">Speakers</a>
     </li>
    {{/if}}
   </ul>
     </div>
   </div>
 </nav>
//Compiling Template by providing path

2. const navbar = handlebars.compile(fs.readFileSync(__dirname + '/templates/partials/navbar.hbs').toString('utf-8'));
// Register Partial

3. handlebars.registerPartial('navbar', navbar);
Continue ReadingUsing Partial in Handlebars and Reusing Code

PIL to convert type and quality of image

Image upload is an important part of the server. The images can be in different formats and after applying certain javascript modifications, they can be changed to different formats. For example, when an image is uploaded after cropping in open event organizer server, it is saved in PNG format. But PNG is more than 5 times larger than JPEG image. So when we upload a 150KB image, the image finally reaching the server is around 1MB which is huge. So we need to decide in the server which image format to select in different cases and how to convert them.

Continue ReadingPIL to convert type and quality of image

File upload progress in a Node app using Socket.io

If you look at the webapp generator, you’ll see that there is an option to upload a zip file containing event data. We wanted to give visual cue to the user when he is uploading to see how much file has uploaded.

We are uploading the file, and giving the generate start command via socket.io events instead of POST requests here.

To observe file upload progress on socket (when sending file using a Buffer), there is an awesome node module available called socketio-upload-progress.

In our webapp you can see we implemented it on the frontend here in the form.js and here in the backend in app.js

Basically on the backend you should add the socketio-file-upload module as a middleware to express

var siofu = require("socketio-file-upload");
var app = express()
    .use(siofu.router)
    .listen(8000);

After a socket is opened, set up the upload directory and start listening for uploads

io.on("connection", function(socket){
    var uploader = new siofu();
    uploader.dir = "/path/to/save/uploads";
    uploader.listen(socket);
});

On the frontend, we’ll listen for an input change on an file input type element whose id is siofu_upload

var socket = io.connect();
var uploader = new SocketIOFileUpload(socket);
uploader.listenOnInput(document.getElementById("siofu_input"));

One thing to note here is that, if you observe percentage of upload on frontend, it’ll give you false values. The correct values of how much data is actually transferred can be found in the backend. So observe progress in backend, and send percentage to frontend using the same socket.

  uploader.on('progress', function(event) {
    console.log(event.file.bytesLoaded / event.file.size)
    socket.emit('upload.progress', {
      percentage:(event.file.bytesLoaded / event.file.size) * 100
    })
});

 

Continue ReadingFile upload progress in a Node app using Socket.io

Adding Google Analytics To All Pages Using Flask

Google Analytics gives a detailed insight about your website including how many people visited, time, demography, how many returning visitors and all such information. It’s a real important tool to have. All you have to do is create a Universal Analytics Tracking code and use it in a javascript code. The only problem is this code needs to be present in all the pages that you wants the analytics data for. So changing any part of the javascript code anytime, needs to be changed in all .html files.

However, there is a better way of doing it in flask. Create a file base.html and write the code:

<script>
(function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,’script’,’https://www.google-analytics.com/analytics.js’,’ga’);

ga(‘create’, ‘<track-code>’, ‘auto’);
ga(‘send’, ‘pageview’);

</script>

Then using the property of jinja2 template extend this file in all the html files, i.e. {% extends ‘gentelella/admin/base.html’ %}. Thus now when you make some change in the above mentioned javascrpt code, you need to change it only in one place and it is changed in all other places.

Continue ReadingAdding Google Analytics To All Pages Using Flask