Skip to content

Instantly share code, notes, and snippets.

View xissy's full-sized avatar

Taeho Kim xissy

View GitHub Profile
@xissy
xissy / getSha1FromFile.js
Last active October 10, 2015 13:18 — forked from guybrush/gist:721762
Get a sha1 hash value from a file.
#!/usr/bin/env node
require('fs').readFile('image.png',function(err, data){
console.log(require('crypto').createHash('sha1').update(data).digest('hex'))
})
@xissy
xissy / getYoutubeVideoInfo.coffee
Last active July 25, 2024 03:38
Get a youtube video information from get_video_info.
request = require 'request'
youTubeMovieInfo =
youTubeMovieId: 'videoId'
url = "http://www.youtube.com/get_video_info?video_id=#{youTubeMovieInfo.youTubeMovieId}"
request.get url, (err, res, body) ->
return callback(false) if err
return callback(false) if res.statusCode isnt 200
@xissy
xissy / pull-to-refresh(android).js
Created October 5, 2012 05:12 — forked from jpurcell/pull-to-refresh(android).js
Tweetie-like pull to refresh and pull to load more. Note that it requries set heights for everything.
// This is the Android version of the Tweetie-like pull to refresh table:
// http://developer.appcelerator.com/blog/2010/05/how-to-create-a-tweetie-like-pull-to-refresh-table.html
var win = Ti.UI.currentWindow;
var alertDialog = Titanium.UI.createAlertDialog({
title: 'System Message',
buttonNames: ['OK']
});
var scrollView = Ti.UI.createScrollView({
@xissy
xissy / encodeToUtf8.coffee
Last active December 19, 2015 00:59
How to get a UTF-8 string from another charset string using node.js, node-icu-charset-detector and node-iconv.
# dependencies.
charsetDetector = require 'node-icu-charset-detector'
Buffer = require('buffer').Buffer
Iconv = require('iconv').Iconv
# this is it.
iconv = new Iconv charsetDetector.detectCharset(data).toString(), 'UTF-8'
buffer = iconv.convert data
text = buffer.toString()
# coding=UTF-8
import nltk
from nltk.corpus import brown
# This is a fast and simple noun phrase extractor (based on NLTK)
# Feel free to use it, just keep a link back to this post
# http://thetokenizer.com/2013/05/09/efficient-way-to-extract-the-main-topics-of-a-sentence/
# Create by Shlomi Babluki
# May, 2013
@xissy
xissy / GroovesharkStreamUrlGetter.java
Last active December 20, 2015 09:19
Get a grooveshark music streaming url with Java, Android and AndroidQuery.
package io.recom.howabout.category.music.net;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
import java.util.regex.Matcher;
@xissy
xissy / .vimrc
Created August 18, 2013 19:24
My .vimrc
filetype off
call pathogen#runtime_append_all_bundles()
filetype plugin indent on
set nocompatible
set modelines=0
set tabstop=4
set shiftwidth=4
@xissy
xissy / parseTreeString.coffee
Created August 28, 2013 22:55
Parse a Stanford CoreNLP parsed string.
treeString = '''(ROOT (S (NP (PRP They)) (VP (VP (VBD were) (VP (VBN cost) (S (ADJP (JJ effective))))) (, ,) (VP (VBD held) (PRT (RP up)) (NP (NP (JJ great)) (, ,) (NP (DT no) (NNS leaks)) (, ,) (NP (DT no) (NNS dyes)) (CC or) (NP (JJ harsh) (NNS chemicals)))) (, ,) (CC and) (VP (VBD had) (NP (NP (DT a) (JJ simple) (NN design)) (PP (IN on) (NP (DT the) (NN outside)))))) (. .)))'''
parsedList = []
wordIndex = 1
parseRecursive = (treeString, currentPosition) ->
treeString = treeString[1..-2]
splittedTokens = treeString.split(' ')
firstToken = splittedTokens[0]
@xissy
xissy / vim8.0_ubuntu16LTS
Created April 24, 2017 16:29
Installing vim 8.0.X with lua, python on Ubuntu 16.04
sudo apt-get remove --purge vim vim-runtime vim-gnome vim-tiny vim-gui-common
sudo apt-get install liblua5.1-dev luajit libluajit-5.1 python-dev ruby-dev libperl-dev libncurses5-dev libatk1.0-dev libx11-dev libxpm-dev libxt-dev
sudo rm -rf /usr/local/share/vim
sudo rm /usr/bin/vim
sudo mkdir /usr/include/lua5.1/include
sudo cp /usr/include/lua5.1/*.h /usr/include/lua5.1/include/
@xissy
xissy / .bashrc
Created May 25, 2017 23:00
AWS EMR .bashrc for Spark
# set the default region for the AWS CLI
export AWS_DEFAULT_REGION=$(curl --retry 5 --silent --connect-timeout 2 http://169.254.169.254/latest/dynamic/instance-identity/document | grep region | awk -F\" '{print $4}')
export JAVA_HOME=/etc/alternatives/jre
export HADOOP_CONF_DIR=/etc/hadoop/conf
export SPARK_HOME=/usr/lib/spark
export SPARK_WORKER_DIR=/var/run/spark/work
export EXTRA_CLASSPATH=/usr/lib/hadoop-lzo/lib/hadoop-lzo.jar:/etc/hive/conf
export SPARK_LOCAL_IP=$(ec2-metadata -o | cut -d ' ' -f2)
export SPARK_LOCAL_HOSTNAME=$(ec2-metadata -h | cut -d ' ' -f2)