Skip to content

Instantly share code, notes, and snippets.

@kashitan
kashitan / server.R
Last active August 29, 2015 13:57
@sbcare宛のTweetを形態素解析してShineで眺めるコード
library(shiny)
library(twitteR)
library(RMeCab)
library(wordcloud)
options(encoding='UTF-8')
Sys.setlocale("LC_ALL", "ja_JP.UTF-8")
# Tweetに絵文字が含まれると"&"の置換でエラーとなるため該当のTweetをNAにする
remove.emoji <- function(x) {
@kashitan
kashitan / comment_lv196871269.txt
Created November 13, 2014 00:29
#みどりぼん 最終回 ニコ生コメント
-1:-53 なるほど、わからん id:BAG85NBK9Idp1FVTLS1xVfgg4lM
0:12 ぱちぱち id:eRE0y9SF7uZs8lsiDyVPYiHni5Q
0:36 プログラマー乙 id:OXUAdFmNJvZ7pnvflx8gb7jFu8g
1:56 電通いくん id:2NheN3H0BzZAIkV7-egRNyqOOis
2:44 すげーいい試み id:DmrIJLCLceiDDhmDpwjwgbg8EP0
2:58 頑張れ頑張れ id:DmrIJLCLceiDDhmDpwjwgbg8EP0
3: 1 絵は2次元だったな id:0dQP-sxzJhPBQ7SMVfJ_R7b5hKo
3:15 ポアソン分布にみえない id:2NheN3H0BzZAIkV7-egRNyqOOis
3:16 俺」BIGDATAの会社いっぱいしっているから教ええるよ id:DmrIJLCLceiDDhmDpwjwgbg8EP0
3:36 帰無仮説 id:DmrIJLCLceiDDhmDpwjwgbg8EP0
<source>
type twitter
consumer_key YOUR_CONSUMER_KEY # Required
consumer_secret YOUR_CONSUMER_SECRET # Required
oauth_token YOUR_OAUTH_TOKEN # Required
oauth_token_secret YOUR_OAUTH_TOKEN_SECRET # Required
tag twitter.raw.tracking # Required
timeline tracking # Required (tracking or sampling or userstream)
keyword CB,MNP,キャッシュバック # Optional (keyword is priority than follow_ids)
lang ja # Optional
@kashitan
kashitan / sample.R
Created April 7, 2015 00:03
formatR確認用Rスクリプト
## comments are retained;
# a comment block will be reflowed if it contains long comments;
#' roxygen comments will not be wrapped in any case
1+1
if(TRUE){
x=1 # inline comments
}else{
x=2;print('Oh no... ask the right bracket to go away!')}
1*3 # one space before this comment will become two!
@kashitan
kashitan / 00-pyspark-setup.py
Last active August 29, 2015 14:23
Spark on EMR用Jupyter設定ファイル
import os
import sys
spark_home = os.environ.get('SPARK_HOME', None)
if not spark_home:
raise ValueError('SPARK_HOME environment variable is not set')
sys.path.insert(0, os.path.join(spark_home, 'python'))
sys.path.insert(0, os.path.join(spark_home, 'python/lib/py4j-0.8.2.1-src.zip'))
execfile(os.path.join(spark_home, 'python/pyspark/shell.py'))
@kashitan
kashitan / sudoers
Last active August 29, 2015 14:26
JupyterHub用/etc/sudoers
# comma-separated whitelist of users that can spawn single-user servers
Runas_Alias JUPYTER_USERS = [user1], [user2]
# the command(s) the Hub can run on behalf of the above users without needing a password
# the exact path may differ, depending on how sudospawner was installed
Cmnd_Alias JUPYTER_CMD = /usr/bin/sudospawner
# actually give the Hub user permission to run the above command on behalf
# of the above users without prompting for a password
jupyter ALL=(JUPYTER_USERS) NOPASSWD:JUPYTER_CMD
@kashitan
kashitan / jupyterhub_config.py
Last active August 29, 2015 14:26
JupyterHub設定ファイル
c.JupyterHub.db_url = 'sqlite:////etc/jupyterhub/jupyterhub.sqlite'
c.JupyterHub.base_url = '/jupyter/'
c.JupyterHub.ssl_key = '[鍵ファイルのパス]'
c.JupyterHub.ssl_cert = '[証明書ファイルのパス]'
c.JupyterHub.cookie_secret_file = '/etc/jupyterhub/jupyterhub_cookie_secret'
c.Authenticator.admin_users = {'管理者ユーザー1', '管理者ユーザー2'}
c.JupyterHub.port = [ポート]
c.Spawner.notebook_dir = '~/notebooks'
c.Authenticator.whitelist = {'管理者ユーザー1', '管理者ユーザー2', '一般ユーザー1', '一般ユーザー2'}
@kashitan
kashitan / .bashrc
Created July 31, 2015 00:19
virtualenv用bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
if [ -f /usr/bin/virtualenvwrapper.sh ]; then
@kashitan
kashitan / ipython_config.py
Created August 4, 2015 00:23
Jupyter notebookのconfigファイル
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 9999 # or whatever you want; be aware of conflicts with CDH
PWDFILE='パスワードファイルのパス'
c.NotebookApp.password = open(PWDFILE).read().strip()
c.NotebookApp.base_url = '/jupyter/'
c.NotebookApp.webapp_settings = {'static_url_prefix':'/jupyter/static/'}
c.NotebookApp.certfile = u'証明書ファイル(*.pem)のパス'
@kashitan
kashitan / detection.R
Last active November 9, 2015 06:17
Detection API実行サンプル
library(httr)
img <- upload_file([画像ファイルのパス])
res <- POST(url = 'https://api.projectoxford.ai/face/v0/detections',
query = list(analyzesFaceLandmarks=FALSE,
analyzesAge=TRUE,
analyzesGender=TRUE,
analyzesHeadPose=FALSE),
add_headers('Content-Type' = 'application/octet-stream',