Skip to content

Instantly share code, notes, and snippets.

@wagamama
wagamama / 0_reuse_code.js
Last active August 29, 2015 14:11
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@wagamama
wagamama / Node.py
Last active May 15, 2021 19:43
Problem Solving with Algorithms and Data Structures - Lists http://interactivepython.org/runestone/static/pythonds/BasicDS/Lists.html
class Node:
def __init__(self,initdata):
self.data = initdata
self.next = None
def getData(self):
return self.data
def getNext(self):
return self.next
@wagamama
wagamama / data-shape.py
Last active August 29, 2015 14:23
Clean Code - Ch. 6 Data Shape
class Square:
def __init__(self):
self.side = 0
class Rectangle:
def __init__(self):
self.width = 0
self.height = 0
class Circle:
@wagamama
wagamama / object-shape.py
Last active August 29, 2015 14:23
Clean Code - Ch. 6 Object Shape
class Shape:
def area(self):
raise Exception
class Square(Shape):
def __init__(self, side):
self._side = side
def area(self):
return self._side ** 2
@wagamama
wagamama / law-of-demeter.py
Created June 27, 2015 01:18
Clean Code - Ch. 6 The Law of Demeter
class C:
def __init__(self):
self.foo = Foo()
def f(self, arg_foo):
# call method of C
self.other_f()
# call method of an object created by f
local_foo = Foo()
import folium
import pandas as pd
TPE_COORDINATES = (25.0375167, 121.5637)
map_tpe = folium.Map(location=TPE_COORDINATES, zoom_start=12)
water = pd.read_csv('water.csv', encoding='big5')
for each in water.iterrows():
lat, lon = each[1][8], each[1][9]
map_tpe.simple_marker(location=(lat, lon), popup=each[1][1], clustered_marker=True)
map_tpe.create_map('water.html')
import folium
import pandas as pd
TPE_COORDINATES = (25.0375167, 121.5637)
map_tpe = folium.Map(location=TPE_COORDINATES, zoom_start=12)
for i in range(1, 13):
trash_can = pd.read_csv('trash_can{}.csv'.format(i))
for each in trash_can.iterrows():
lat, lon = each[1][4], each[1][3]
map_tpe.simple_marker(location=(lat, lon), clustered_marker=True)
@wagamama
wagamama / wifi.py
Last active November 1, 2015 04:27
import folium
import xmltodict
TPE_COORDINATES = (25.0375167, 121.5637)
map_tpe = folium.Map(location=TPE_COORDINATES, zoom_start=12)
with open('freeWifi.xml') as fd:
wifi = xmltodict.parse(fd.read())
for each in wifi['NewDataSet']['hotspot']:
lat, lon = each['LAT'], each['LNG']
text = ', '.join((each['AREA'], each['HOTSPOT_NAME'], each['ADDRESS']))
import folium
import xmltodict
TPE_COORDINATES = (25.0375167, 121.5637)
map_tpe = folium.Map(location=TPE_COORDINATES, zoom_start=12)
with open('freeWifi.xml') as fd:
toilet = xmltodict.parse(fd.read())
toilet = toilet['soap:Envelope']['soap:Body']['GetToiletResponse']['GetToiletResult']['diffgr:diffgram']
for each in toilet['NewDataSet']['Table']:
lat, lon = each['Lat'], each['Lng']