Instantly share code, notes, and snippets.

@ToQoz
ToQoz / twitter_fav.py
Created May 29, 2011
twitter APIから適当にfav取得
View twitter_fav.py
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import sys, tweepy, urllib, urllib2, simplejson
consumer_key = ""
consumer_secret = ""
access_key = ""
access_secret = ""
def getAuth():
auth = tweepy.OAuthHandler(consumer_key,consumer_secret)
auth.set_access_token(access_key,access_secret)
@ToQoz
ToQoz / proccessing_on_canvas.py
Created May 29, 2011
canvas上でproccessing.js使うサンプル
View proccessing_on_canvas.py
<!DOCTYPE html>
<html>
<head>
<title>Processing</title>
<meta charset="utf-8">
</head>
<body>
<canvas width="500" height="400"></canvas>
<script src="js/processing-1.1.0.min.js"></script>
@ToQoz
ToQoz / fragment_url.js
Created May 29, 2011
#!使ってタブチェンジとかするサンプル
View fragment_url.js
/*
* https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js
* https://github.com/cowboy/jquery-hashchange/raw/v1.3/jquery.ba-hashchange.js
*/
(function($){
var tab1 = function() {
$("#tab1").hide();
$("#tab2").hide();
$.ajax({
url: "change_tabs",
@ToQoz
ToQoz / dynamic_define_method.py
Created Jul 26, 2011
pythonでrubyのdefine_method的なことをやってみる。
View dynamic_define_method.py
lang_list = ["python",
"ruby"]
class Language():
pass
for lang in lang_list:
def _get_language(self, lang=lang):
return "[language] %s" % (lang)
setattr(Language, "get_" + lang, _get_language)
@ToQoz
ToQoz / dict_to_string.py
Created Jul 30, 2011
python 辞書から文字列
View dict_to_string.py
"&".join([k+"="+v for k, v in params.items()])
@ToQoz
ToQoz / vows_intro.coffee
Created Aug 13, 2011
vows intro written in coffeescript
View vows_intro.coffee
# coffee version of vows intro in http://vowsjs.org/
exports.Strawberry = () ->
this.color = '#ff0000'
exports.Strawberry.prototype =
isTasty: () -> true
exports.Banana = ()->
this.color = '#fff333'
@ToQoz
ToQoz / favter.rb
Created Aug 14, 2011 — forked from dnpp73/favter.rb
favorit爆撃を与えてターゲットのデスクトップをGrowlで埋めるなどします
View favter.rb
#coding: utf-8
require 'twitter'
Twitter.configure do |config|
config.consumer_key = YOUR_CONSUMER_KEY
config.consumer_secret = YOUR_CONSUMER_SECRET
config.oauth_token = YOUR_OAUTH_TOKEN
config.oauth_token_secret = YOUR_OAUTH_TOKEN_SECRET
end
@ToQoz
ToQoz / a_smart_dashboard_have_my_id.user.js
Created Aug 14, 2011 — forked from mitukiii/a_smart_dashboard_have_my_id.user.js
Dashboardのみで動作、ポストが自分のidを含んでいるかの判定をより厳密に、User CSSの「A smart dashboard is_mine」に依存しないように変更した。
View a_smart_dashboard_have_my_id.user.js
// ==UserScript==
// @name A smart dashboard have my id
// @namespace http://mitukiii.jp/
// @description TumblrのDashboardで自分からReblogされた/自分のidを含んだpostを折り畳むスクリプト
// @include http://www.tumblr.com/dashboard*
// @author mitukiii
// @compatibility Firefox 5.0(Scriptish 0.1), Chrome 12.0.742.112, Opera 11.50
// @charset UTF-8
// @version 0.0.2.20110707180600
// ==/UserScript==
@ToQoz
ToQoz / 0normal.coffee
Created Aug 21, 2011
Titaniumで不幸にならない非同期通信
View 0normal.coffee
# 不幸になる書き方
get_timeLine = ()->
xhr = Ti.Network.createHTTPClient
xhr.open 'GET', 'http://example.com/timeline.json'
xhr.onload = ()->
res = JSON.parse(@responseText)
for v in res
# ここでforとか回してゴリゴリviewを作っていく
# addeventlistenerが多いなど複雑なviewだとonload内が肥大する
# どこがviewを作っているコードとロジックがごちゃごちゃ
@ToQoz
ToQoz / snake_to_camel_case.js
Created Sep 28, 2011
javascriptでrouwerCamelCaseからsnake_caseに変える
View snake_to_camel_case.js
function convertSnakeToCamelCase(str) {
return str.replace(/_([a-z])/g, function(){return RegExp.$1.toUpperCase()});
}