Skip to content

Instantly share code, notes, and snippets.

View tadyjp's full-sized avatar

tady (GitHub) tadyjp

View GitHub Profile
@tadyjp
tadyjp / compare_name_with_hiragana
Created June 5, 2012 05:55
アルファベット表記の名前をひらがなで比較
// require underscore.js
var list = [
['a', 'i', 'u', 'e', 'o'],
['k', 'g'],
['s', 'z'],
['t', 'd'],
['n'],
['h', 'b', 'p'],
['m'],
@tadyjp
tadyjp / has_many_association_collection.rb
Created June 9, 2012 09:58
[rails] has_many association; collection count, size and length
# in user model:
# has_many :pins_relationship, class_name: 'Action', conditions: {kind: 'pin'}
# has_many :pins, through: :pins_relationship, source: :stuff, uniq: true
it "pin place (duplicate check)" do
@alice.pins << Stuff.find_or_create_by_kind_and_name!(kind: 'landmark', name: "お気に入り喫茶店")
@alice.pins << Stuff.find_or_create_by_kind_and_name!(kind: 'landmark', name: "お気に入り喫茶店")
@alice.pins.where(kind: 'landmark', name: "お気に入り喫茶店").count.should == 2
@alice.pins.where(kind: 'landmark', name: "お気に入り喫茶店").size.should == 2
@alice.pins.where(kind: 'landmark', name: "お気に入り喫茶店").length.should == 1
@tadyjp
tadyjp / listview.selectionchanged.js
Created June 12, 2012 10:22
listviewで選択した時のイベント
listView.addEventListener("selectionchanged", function(e){
listView.selection.getItems().done(function(res){
console.dir(res);
});
});
@tadyjp
tadyjp / WinJS.Binding.List#onitemchanged.js
Created June 13, 2012 05:29
WinJS.Binding.List#onitemchanged
setInterval(function () {
var t = (new Date()).toISOString();
console.log(t);
Data.items.getAt(0).title = t;
}, 1000);
@tadyjp
tadyjp / gist:3076597
Created July 9, 2012 13:33
get friends of friends list on facebook
curl -O -b cookie.txt "https://www.facebook.com/ajax/browser/list/allfriends/?uid=<TARGET_ID>&__user=<MY_ID>&__a=1start=0"
@tadyjp
tadyjp / gist:3159575
Created July 22, 2012 12:58
Getting facebook friends name on Koala
# Koalaでfacebookの友人の名前を言語表記(この場合は日本語)で取得するサンプル
# ref. https://github.com/arsduo/koala/
@graph = Koala::Facebook::API.new(oauth_access_token)
@graph.fql_multiquery(
{"ids" => "SELECT uid2 FROM friend WHERE uid1=me()",
"names" => "SELECT id, name FROM profile WHERE id IN (SELECT uid2 FROM #ids)" },
{:locale => "ja_JP"})
@tadyjp
tadyjp / run.sh
Created August 22, 2012 12:05
run titanium CLI for iPad simulator
#!/bin/sh
# titaniumでiPadシミュレーターをコマンドラインから起動
python ~/Library/Application\ Support/Titanium/mobilesdk/osx/2.1.1.GA/iphone/builder.py simulator 5.1 "`pwd`" jp.tady.yonkoma yonkoma ipad
@tadyjp
tadyjp / External_links_in_setting_flyout.js
Created September 4, 2012 16:31
External links in setting flyout.
@tadyjp
tadyjp / detect_active_div_element.js
Created September 4, 2012 18:21
Detect active div element
var $prevDiv;
$("div").click(function(e){
$this = $(e.currentTarget);
console.log(e);
if($this.attr("id") !== ""){
$this.css("background-color", "red");
$prevDiv && $prevDiv.css("background-color", "white");
$prevDiv = $this;
e.stopPropagation();
}
@tadyjp
tadyjp / ruby.py
Created October 12, 2012 12:14
Sublime Text2のSublimeLinterでruby1.9のハッシュリテラル("key: value"形式)をSyntax Errorを回避方法 ref: http://qiita.com/items/a2d18686343cb1881031
CONFIG = {
'language': 'Ruby',
# 'executable': 'ruby',
'executable': '/Users/<ユーザー名>/.rvm/rubies/ruby-1.9.3-p194/bin/ruby',
'lint_args': '-wc'
}
```
以上で、煩わしい偽Syntax Errorを回避できる。