Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Use open source software to develop ideas at work

Avatar for Sammy Fung Sammy Fung
October 03, 2014

Use open source software to develop ideas at work

Avatar for Sammy Fung

Sammy Fung

October 03, 2014
Tweet

More Decks by Sammy Fung

Other Decks in Technology

Transcript

  1. Sammy Fung • Python Developer – Perl → PHP →

    Python • President at OpenSource.HK • Community Volunteer in HK & Asia – GNOME.Asia, Mozilla......
  2. “ Free software means software that respects users' freedom and

    community. ” http://www.gnu.org/philosophy/free-sw.html
  3. 4 Essential Freedoms • Freedom 0: Run the program. •

    Freedom 1: Open Source to study and change it. • Freedom 2: Re-distribute the program. • Freedom 3: Distribute your modified versions as free software.
  4. Operating System • Linux – Server, Desktop, Embedded System. –

    Mobile (Android). • 1983: GNU projects developed many free software programs replacing proprietary programs on UNIX platforms. • 1991: Linus Torvalds released first Linux kernel on internet, then developers integrate with GNU softwares (GNU/Linux) and distribute a new OS. • Documentary Movie: Revolution OS (2001).
  5. Web Server • Apache Software Foundation. • Apache HTTP Server

    (Web Server). • Most popular HTTP server since April 1996. • 1995: First release • 2009: 1st web server serving 100 million websites. • August 2014: 47.92% market share (1st) – http://news.netcraft.com/archives/2014/08/27/august-2014- web-server-survey.html • Documentary Movie: Revolution OS (2001).
  6. Applications • Developing Web Applications and Mobile Applications running on

    OS platforms. • Huge amount of free software (open source software) are esstential and used to develop, manage and operate web & mobile apps and their platforms. • Programming Languages: – PHP, Python, Ruby...... • Web Frameworks, CMS, Blog......: – Wordpress, Drupal, Django, Joomla......
  7. Web Browser • Mozilla Foundation (Found in 2003). • Firefox

    Web Browser. • Market Share: 15-20% (2014), 25-30% (2011). • 1998: Netscape Communications Corp (creator of Netscape Navigator web browser) created Mozilla project to coordinate open source version of internet suite. – Internet Suite: Web + Mail / Newsgroup + Web Composer + IRC. • 2002: 1st release Firefox web browser (experimental branch of Mozilla project). • Sept 2014: Firefox 32. • Documentary Movie: Code Rush
  8. ASP

  9. WeatherHK • Reports – Hourly Current Weather Information – Weather

    Forecast • Warning – Tropical Signal issuing, updates, pre-warning.
  10. TCTrack • Plot paths of any active Tropical Cyclones –

    On Google Map • Probably the 1st Tropical Cyclones map in Hong Kong using Google Map API. – sammy.hk → Weather Undergroud Hong Kong → HKO – Current Paths. – Forecast Paths. – Tweets JTWC updates to Twitter. – Data Sources: • JTWC • HKO
  11. Five Star Open Data 1.make your stuff available on the

    Web (whatever format) under an open license. 2.make it available as structured data (e.g., Excel instead of image scan of a table) 3.use non-proprietary formats (e.g., CSV instead of Excel) 4.use URIs to denote things, so that people can point at your stuff. 5.link your data to other data to provide context. 5stardata.info by Tim Berners-Lee, the inventor of the Web.
  12. Scrapy • Python web scraping framework. • Scrap websites and

    extract structured data. • From data mining to monitoring and automated testing.
  13. Scrapy Features • Define your own data structures. • Write

    spiders to extract data. • Built-in XPath selectors to extracting data. • Built-in JSON, CSV, XML output. • Interactive shell console, telnet console, logging...... • Scrapyd – a daemon providing Web API and simple Web UI. – http://localhost:6800
  14. Creating a Scrapy Project • Creating a new scrapy project.

    – $ scrapy startproject <project name> • Define your data structure • Write your first spider – Test with scrapy shell console • Output / Store collected data – Output with built-in supported formats – Store to database / object store.
  15. Scrapy + Django • Django – Python web framework •

    Installing Django via pip – $ pip install django • Scrap with Scrapy and store data with Django
  16. Creating django project • Creating a Django project. – $

    django-admin.py startproject <project name> • Define django settings. – <project name>/settings.py – Create database, tables and first django user. • $ python manage.py syncdb – Define installed django apps with INSTALLED_APPS array.
  17. Creating a Django App • Create your own django app.

    – $ python manage.py startapp <new app name> • Define data model at models.py – $ python manage.py syncdb • Activate django admin UI at admin.py – Add URL router to access admin UI.
  18. Define django data model class WeatherData(models.Model): reporttime = models.DateTimeField() station

    = models.CharField(max_length=3) temperture = models.FloatField(null=True, blank=True) humidity = models.IntegerField(null=True, blank=True)
  19. Enable django admin ui • Adding to INSTALLED_APPS at settings.py

    – django.contrib.admin • Adding URL router at urls.py – $ python manage.py runserver • Access admin UI – http://127.0.0.1:8000/admin
  20. Scrapy + Django • Define django environment at scrapy settings.

    – Load django configuration. • Use Scrapy DjangoItem class – Insteads of Item and Field class – Define which django data model should be linked with. • Query and insert data at scrapy pipelines.
  21. hk0weather • Weather Data Project. – https://github.com/sammyfung/hk0weather – convert weather

    information to JSON data from HKO webpages. – python + scrapy + django
  22. hk0weather • Hong Kong Weather Data. – 20+ HKO weather

    stations in Hong Kong. – Regional weather data. – Rainfall data. – Weather forecast report.
  23. Hk0weather installation • Setup and activate a python virtual enviornment,

    and install scrapy and django with pip. • Clone hk0weather from GitHub – $ git clone https://github.com/sammyfung/hk0weather.git • Setup database connection at Django and create database, tables and first django user. • Scrap regional weather data – $ scrapy crawl regionalwx -t json -o regional.json
  24. Hong Kong Linux User Group • http://www.linux.org.hk/ • Re-established in

    1997. • Linux Talks, Seminiars and Workshops. • Linux Cafe meetups. • Linux Exhibitions and Demostrations.
  25. Open Source Hong Kong • http://www.opensource.hk • Established in 2008.

    • Events: Workshops, Hackathons, Conferences.
  26. Hong Kong Creative Open Technology Association • http://www.cota.hk • Established

    in 2014. • HK registered limited company in guarantee. • Non-profit organization. (in final process) • Promoting Open Standards, Free and Open Source Software, Open Hardware, Free Culture Works, Open Content and Creative Commons. • Work on projects and events. – eg. Hong Kong Open Source Conference 2014.
  27. “ Free software means software that respects users' freedom and

    community. ” http://www.gnu.org/philosophy/free-sw.html
  28. Welcome to invite me to...... • Meetings, Talks, Workshops and

    Events – at your company and schools. • Projects – Development – Consultation • Let's get a name card.