Use open source software to develop ideas at work

Embed Size (px)

DESCRIPTION

At BarCamp Macau 2014, I give a talk about open source software, open source job board for drupal CMS, scrapy + django, and open source community.

Citation preview

  • 1. Use open sourcesoftwareto develop ideasat workSammy FungBarCamp Macau 2014

2. Sammy Fung Python Developer Perl PHP Python President at OpenSource.HK Community Volunteer in HK & Asia GNOME.Asia, Mozilla...... 3. Future market leader must be the one whichuse and contribute open source. 4. FREEDOM 5. Free software meanssoftware that respectsusers' freedom andcommunity. http://www.gnu.org/philosophy/free-sw.html 6. 4 Essential Freedoms Freedom 0: Run the program. Freedom 1: Open Source to study and changeit. Freedom 2: Re-distribute the program. Freedom 3: Distribute your modified versionsas free software. 7. Ecosystem inTechnologyInnovation 8. Ecosystem in Technology Innovation Operating Systems Servers with Applications Clients 9. Operating System Linux Server, Desktop, Embedded System. Mobile (Android). 1983: GNU projects developed many free softwareprograms replacing proprietary programs on UNIXplatforms. 1991: Linus Torvalds released first Linux kernel oninternet, then developers integrate with GNU softwares(GNU/Linux) and distribute a new OS. Documentary Movie: Revolution OS (2001). 10. 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). 11. Applications Developing Web Applications and Mobile Applicationsrunning on OS platforms. Huge amount of free software (open source software)are esstential and used to develop, manage andoperate web & mobile apps and their platforms. Programming Languages: PHP, Python, Ruby...... Web Frameworks, CMS, Blog......: Wordpress, Drupal, Django, Joomla...... 12. Web Browser Mozilla Foundation (Found in 2003). Firefox Web Browser. Market Share: 15-20% (2014), 25-30% (2011). 1998: Netscape Communications Corp (creator of NetscapeNavigator web browser) created Mozilla project to coordinate opensource version of internet suite. Internet Suite: Web + Mail / Newsgroup + Web Composer + IRC. 2002: 1st release Firefox web browser (experimental branch ofMozilla project). Sept 2014: Firefox 32. Documentary Movie: Code Rush 13. Example 1Open SourceJob Board 14. Many years ago... 15. Looking for a job 16. At a popular job site 17. !Got error! 18. ?Why? 19. !You should get it! 20. !High! 21. ...in Market Share 22. Also...... 23. !High! 24. ASPCFM Nginx+PHP 25. ASP 26. ...in Market Share 27. ......So...... 28. .........I decided... 29. !Develop open sourcejob board software 30. Drupal 6 Development starting fromDrupal 6 module 31. Never launched 32. In this year 33. Drupal 7 Porting from Drupal 6 toDrupal 7 34. API API Changed 35. codesChanged some codes 36. GitHub: sammyfung / drupal7-job 37. Job Posting 38. Job Category 39. CompanyInformation 40. RSSRSS Feeds toeach job category. 41. Open Source 42. You can own yourjob board now 43. ?How ? 44. LinuxInstall a Linuxweb server. 45. DrupalInstall Drupal ContentManagement System 46. DrupalInstall and enable this jobboard module for Drupal 47. !Done! 48. job.opensource.hk 49. ...If you got any jobpositions which requiresany one of open sourcesoftware skill sets.... 50. Post it tojob.opensource.hk 51. !It's Free of Charge! 52. FutureRoadmap 53. DjangoRelease aDjango module 54. Wordpres?Release Wordpressmodule ? 55. Javascript?Release Javascriptmodule ? 56. Commercialize 57. Example 2Open SourceWeather DataParser 58. http://www.twitter.com/weatherhk 59. WeatherHK Reports Hourly Current Weather Information Weather Forecast Warning Tropical Signal issuing, updates, pre-warning. 60. WeatherHK Interview by MetroPop in 2009. 61. http://sammy.hk/projects/tctrack/tctrack.php 62. TCTrack Plot paths of any active Tropical Cyclones On Google Map Probably the 1st Tropical Cyclones map in Hong Kong using Google MapAPI. sammy.hk Weather Undergroud Hong Kong HKO Current Paths. Forecast Paths. Tweets JTWC updates to Twitter. Data Sources: JTWC HKO 63. Open Data 64. Five Star Open Data1.make your stuff available on the Web (whatever format)under an open license.2.make it available as structured data (e.g., Excel instead ofimage 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 yourstuff.5.link your data to other data to provide context.5stardata.info by Tim Berners-Lee, the inventor of the Web. 65. Web Scrapinga computer softwaretechnique of extractinginformation from websites.(Wikipedia) 66. Web Scrapingwith Scrapy 67. Scrapy Python web scraping framework. Scrap websites and extract structured data. From data mining to monitoring andautomated testing. 68. 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 69. Scrapy Installation$ apt-get install python python-virtualenvpython-pip$ virtualenv env$ source env/bin/activate$ pip install scrapy 70. Creating a Scrapy Project Creating a new scrapy project. $ scrapy startproject 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. 71. Scrapy + Django Django Python web framework Installing Django via pip $ pip install django Scrap with Scrapy and store data with Django 72. Creating django project Creating a Django project. $ django-admin.py startproject Define django settings. /settings.py Create database, tables and first django user. $ python manage.py syncdb Define installed django apps withINSTALLED_APPS array. 73. Creating a Django App Create your own django app. $ python manage.py startapp Define data model at models.py $ python manage.py syncdb Activate django admin UI at admin.py Add URL router to access admin UI. 74. Define django data modelclass 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) 75. 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 76. 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 linkedwith. Query and insert data at scrapy pipelines. 77. hk0weather 78. hk0weather Weather Data Project. https://github.com/sammyfung/hk0weather convert weather information to JSON data fromHKO webpages. python + scrapy + django 79. hk0weather Hong Kong Weather Data. 20+ HKO weather stations in Hong Kong. Regional weather data. Rainfall data. Weather forecast report. 80. 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 createdatabase, tables and first django user. Scrap regional weather data $ scrapy crawl regionalwx -t json -o regional.json 81. How can youuse & participateopen sourcesoftware ? 82. Community 83. 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. 84. Open Source Hong Kong http://www.opensource.hk Established in 2008. Events: Workshops, Hackathons, Conferences. 85. Monthly Events -Open Source Workshops 86. OpenSource.HK Hackathons 87. Hong Kong Open SourceConferences 88. Hong Kong Creative OpenTechnology 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 SourceSoftware, Open Hardware, Free Culture Works, OpenContent and Creative Commons. Work on projects and events. eg. Hong Kong Open Source Conference 2014. 89. FREEDOM 90. Free software meanssoftware that respectsusers' freedom andcommunity. http://www.gnu.org/philosophy/free-sw.html 91. Future market leader must be the one whichuse and contribute open source. 92. Welcome to invite me to...... Meetings, Talks, Workshops and Events at your company and schools. Projects Development Consultation Let's get a name card. 93. Thank [email protected]