Skip to content

Instantly share code, notes, and snippets.

@ToQoz
ToQoz / twitter_fav.py
Created May 29, 2011 12:49
twitter APIから適当にfav取得
#! /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 12:51
canvas上でproccessing.js使うサンプル
<!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 15:38
#!使ってタブチェンジとかするサンプル
/*
* 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 July 26, 2011 07:44
pythonでrubyのdefine_method的なことをやってみる。
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 July 30, 2011 03:31
python 辞書から文字列
"&".join([k+"="+v for k, v in params.items()])
@ToQoz
ToQoz / vows_intro.coffee
Created August 13, 2011 15:43
vows intro written in coffeescript
# 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 August 14, 2011 11:52 — forked from dnpp73/favter.rb
favorit爆撃を与えてターゲットのデスクトップをGrowlで埋めるなどします
#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 August 14, 2011 17:35 — forked from rummelonp/a_smart_dashboard_have_my_id.user.js
Dashboardのみで動作、ポストが自分のidを含んでいるかの判定をより厳密に、User CSSの「A smart dashboard is_mine」に依存しないように変更した。
// ==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 August 21, 2011 10:02
Titaniumで不幸にならない非同期通信
# 不幸になる書き方
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 September 28, 2011 07:54
javascriptでrouwerCamelCaseからsnake_caseに変える
function convertSnakeToCamelCase(str) {
return str.replace(/_([a-z])/g, function(){return RegExp.$1.toUpperCase()});
}