Skip to content

Instantly share code, notes, and snippets.

View darashi's full-sized avatar

Yoji Shidara darashi

View GitHub Profile
SELECT sum(小計) AS count, year(日付) AS year FROM 'https://ckan.pf-sapporo.jp/dataset/c89f65e7-45a8-4ab2-b94d-494ae192c70f/resource/b83606f6-3aa2-4e0c-8a1a-509dd36be2ae/download/patients_summary.csv' GROUP BY year ORDER BY year;
@darashi
darashi / grit-kvs.rb
Created March 6, 2012 04:47
toy example of git-backended KVS
#!/usr/bin/env ruby
require 'grit'
class Database
def initialize(path)
@repository = Grit::Repo.new(path)
end
def find(key)
@darashi
darashi / hello.c
Created February 10, 2012 16:42
HELLO WORLD from Arduino
#define LED 13
#define T 100 // speed
char *morse_pattern[] = {
"._", "_...", "_._.", "_..", ".", ".._.", "__.",
"....", "..", ".___", "_._", "._..", "__",
"_.", "___", ".__.", "__._", "._.", "...", "_",
".._", "..._", ".__", "_.._", "__._", "__.."
};
require File.join(File.dirname(__FILE__), 'spec_helper')
describe HikiDoc, '(character)' do
(1..6).each do |i|
it "に#{'!'*i}helloを渡すとH#{i}になる" do
HikiDoc.to_xhtml("#{'!'*i}hello").should == "<h#{i}>hello</h#{i}>\n"
end
end
it 'に!!!!!!!helloを渡すと<h6>!hello</h6>になる' do
HikiDoc.to_xhtml('!!!!!!!hello').should == "<h6>!hello</h6>\n"
@darashi
darashi / tapg.rb
Created November 20, 2009 20:11
tapg: tapp for "g"
def tapg
require 'rubygems'
require 'g'
tap { g block_given? ? yield(self) : self }
end
#!/bin/sh
cd ..
env -i git reset --hard
jekyll
@darashi
darashi / eyefi_receiver.rb
Created June 11, 2009 06:19
Eye-fi receiver
#!/usr/bin/ruby
#
# Eye-fi receiver
# -- An imcomplete implementation of Gallery Remote Protocol Server
# by SHIDARA Yoji <[email protected]>
#
# see http://codex.gallery2.org/Gallery_Remote:Protocol
#
require 'fileutils'
require 'sinatra'
@darashi
darashi / git_commit_header.rb
Created May 20, 2009 11:44
add X-Git-Commit header to Rack application
# Rack middleware to insert git commit id into http response header
# For Rails, put this script under RAILS_ROOT/config/initializers
module Rack
class GitCommitHeader
def initialize(app)
@app = app
c = `git rev-parse HEAD`.chomp
@commit = (c =~ /^[0-9a-f]{40}$/) ? c : nil
end
@darashi
darashi / saybot.rb
Created March 20, 2009 13:16
irc say bot (for OSX)
#!/usr/bin/env ruby1.9
require 'logger'
require 'rubygems'
require 'net/irc'
class IrcClient < Net::IRC::Client
def initialize(*args)
super
@darashi
darashi / workshops_at_sapporo.rb
Created March 14, 2009 11:37
札幌で開催される勉強会を抽出する
#!/usr/bin/env ruby1.9
# encoding: utf-8
require 'open-uri'
require 'rubygems'
require 'icalendar'
uri = "http://www.google.com/calendar/ical/fvijvohm91uifvd9hratehf65k%40group.calendar.google.com/public/basic.ics"