Skip to content

Instantly share code, notes, and snippets.

@sawamur
sawamur / eyefi_receiver.rb
Created January 12, 2010 06:02 — forked from darashi/eyefi_receiver.rb
Eye-fi reciver for sinatra
#!/usr/bin/ruby
#
# Eye-fi receiver
# -- An imcomplete implementation of Gallery Remote Protocol Server
# by SHIDARA Yoji <dara@shidara.net>
#
# see http://codex.gallery2.org/Gallery_Remote:Protocol
#
require 'fileutils'
require 'sinatra'
#import memcache
import threading
import time
import sys
import urllib2
import random
url = "http://example.com/yourappplication"
total_num = 1000
@sawamur
sawamur / gist:1150505
Created August 17, 2011 00:19
To convert a time in PDT to JST
require 'active_support/core_ext'
# need "core_ext" to load timezone modules
Time.zone = "Pacific Time (US & Canada)"
# There's no timezone just for 'PDT'.
t = Time.zone.parse("2011-08-22 14:00:00")
p t
# => Mon, 22 Aug 2011 14:00:00 PDT -07:00
p t.in_time_zone("Tokyo")
@sawamur
sawamur / gist:1327144
Created October 31, 2011 08:57
JS中級コース向けレベルチェック
//下記ソースを読んで設問に答えよ
function User(name){
this.name = name;
}
User.prototype.introduce = function(){
return "Hi! My name is " + this.name;
};
@sawamur
sawamur / gist:1363165
Created November 14, 2011 03:26
ある緯度経度範囲内にある駅データをdbpediaから取得するSPARQLクエリ
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX geo:<http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX geo:<http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX dbpedia_ont: <http://dbpedia.org/ontology/>
SELECT * WHERE {
?link rdfs:label ?title;
rdfs:comment ?comment;
geo:lat ?lat;
geo:long ?long.
?link rdf:type dbpedia_ont:Station.
@sawamur
sawamur / gist:1508380
Created December 22, 2011 00:38
JS中級コース向 サンプルコード
// 実装 : 一箇所バグあり
Date.prototype.strftime = (function () {
function strftime(format) {
var date = this;
return (format + "").replace(/%([a-zA-Z])/g,
function (m, f) {
var formatter = Date.formats && Date.formats[f];
# from string
addrs = Doko.parse("..\n住所\n 東京都港区芝浦3-41 \n..\n...")
p addrs #=> ["東京都港区芝浦3-41"]
# from url
addrs = Doko.parse("http://r.tabelog.com/tokyo/A....")
p addrs #=> ["神奈川県横浜市中区.."]
@sawamur
sawamur / gist:4066035
Created November 13, 2012 14:32
Casper Sample
casper = require('casper').create()
casper.start "http://twitter.com/sawamur"
casper.then ->
@test.assertNotVisible(".signup-only")
@click ".js-follow-btn:nth-of-type(1)"
casper.then ->
@test.assertVisible(".signup-only")
@sawamur
sawamur / gist:4066212
Created November 13, 2012 15:08
casper2
casper.start "http://twitter.com",->
@fill "form[action='https://twitter.com/sessions']"
,{"session[username_or_email]": "foobar","session[password]": "xxxxx"}
,true
casper.then ->
console.log @getCurrentUrl()
@click "#tweet-box-mini-home-profile"
casper.then ->
@sawamur
sawamur / gist:4256670
Created December 11, 2012 07:57
sequence diagram markup language / Draft
user#foo -> server#web1 -sql-> db
true: ->
#web1 -mail-> user#foo
user -> server#web1 -> api#twitter
true: ->
server#web1 -> api#facebook
true: ->
db -> server#web1
false: ->