Skip to content

Instantly share code, notes, and snippets.

@sangheestyle
sangheestyle / worldmap_moto_x.html
Created December 4, 2013 05:58
'moto x' 키워드로 해서 지난 6주간 트위터에서 트윗을 받아서 트윗한 사람의 location 을 알아내서 구글 차트 툴스의 geomap 에 맵핑한 것. 로딩하는데 시간이 좀 걸리는게 흠. (20초까지도 걸림)
<html>
<head>
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript'>
google.load('visualization', '1', {'packages': ['geomap']});
google.setOnLoadCallback(drawMap);
function drawMap() {
var data = google.visualization.arrayToDataTable([
['City', 'Number of tweet for moto x'],
@sangheestyle
sangheestyle / gist:7867428
Last active December 30, 2015 18:28
Scene: Official Twitter App for knowing mobile platform
<!--
You are free to copy and use this sample in accordance with the terms of the
Apache license (http://www.apache.org/licenses/LICENSE-2.0.html)
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>
@sangheestyle
sangheestyle / Scene_4_number_of_tweet_per_weekday_per_week
Last active December 30, 2015 20:19
Scene_4: Weekly trend based on weekday for tweet
<!--
You are free to copy and use this sample in accordance with the terms of the
Apache license (http://www.apache.org/licenses/LICENSE-2.0.html)
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>
@sangheestyle
sangheestyle / Scene_3_hourly_trends
Last active December 30, 2015 20:29
Scene_3: Hourly trends (tweet per hour) without outlier (exclude 31/10, 1/11, 19/11)
@sangheestyle
sangheestyle / Scene2_Geo_Chart
Last active December 30, 2015 20:39
Scene2: Geo Chart
<!--
You are free to copy and use this sample in accordance with the terms of the
Apache license (http://www.apache.org/licenses/LICENSE-2.0.html)
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Google Visualization API Sample</title>
@sangheestyle
sangheestyle / gist:8691435
Last active September 2, 2022 10:37
Removing punctuations, stop words, and stemming the contents with NLTK
import os
import json
import shutil
from subprocess import call
import cld
def read_json(file_path):
json_data = open(file_path)
data = json.load(json_data)
return data
@sangheestyle
sangheestyle / gist:9058886
Last active August 29, 2015 13:56
Python: groupby with itemgetter
# Python: groupby with itemgetter
from itertools import groupby
from operator import itemgetter
# [title, groupID, description]
seq = [["nameA", 0, "descriptionA"], ["nameB", 1, "descriptionB"], ["nameC", 0, "descriptionC"]]
seq.sort(key = itemgetter(1))
groups = groupby(seq, itemgetter(1))
print [[item[0] for item in data] for (key, data) in groups]
@sangheestyle
sangheestyle / gist:9088708
Last active August 29, 2015 13:56
Parse a file to make group items.
from collections import defaultdict
def read_team_info(path):
status = "None"
total = defaultdict(list)
team_info = []
fp = open(path, "r")
for line in fp:
line = line.rstrip()
if len(line) == 0:
@sangheestyle
sangheestyle / mapper.py
Created March 11, 2014 09:44
python and pig: simple word counter for Hadoop
#!/usr/bin/env python
import sys
import string
exclude = set(string.punctuation)
for line in sys.stdin:
line = line.strip()
line = ''.join(ch for ch in line if ch not in exclude)
line = ''.join([i for i in line if not i.isdigit()])
@sangheestyle
sangheestyle / bug_topic.py
Created March 18, 2014 04:58
python: extract only 'bug fixed' desc
import json
import cld
input_json_file = 'apps_public_m_t_desc.json'
output_bugs_desc_file = 'bugs_desc.txt'
with open(input_json_file) as fp:
json_contents = []
bugs_desc = []
for line in fp.readlines():