Skip to content

Instantly share code, notes, and snippets.

View komagata's full-sized avatar

Masaki Komagata komagata

View GitHub Profile
@komagata
komagata / array_cat.php
Created December 28, 2011 11:30
array cat
<?php
$foo = array();
$a = array(1,2,3);
$b = array(4,5,6);
$foo += $a;
$foo += $b;
print_r($foo);
?>
// result
@komagata
komagata / list-of-tech-companys-store-page.md
Created November 18, 2011 07:58 — forked from juno/list-of-tech-companys-store-page.md
List of Tech Company's Store Page

List of Tech Company's Store Page

all suggestions are welcome => @junya

require 'date'
class Date
def weekday?
(1..5).include?(wday)
end
end
@komagata
komagata / config.yml
Created October 13, 2011 10:45
Lokka database config for mysql.
production:
dsn: <%= ENV['DATABASE_URL'] || ENV['DUOSTACK_DB_MYSQL'] %>
development:
dsn: mysql://root:@localhost/lokka
test:
dsn: sqlite3://<%= root %>/db/test.sqlite3
@komagata
komagata / app.rb
Created September 22, 2011 08:32
oauth2 sample
require 'rubygems'
require 'sinatra'
require 'oauth2'
require 'json'
configure :production do
@@client = OAuth2::Client.new(
'xxxxxxxxxxxxx',
'xxxxxxxxxxxxxxxxxxxxxxxx',
:site => 'https://graph.facebook.com'
@komagata
komagata / prefectures.yml
Created September 15, 2011 09:54
Japanese prefectures.
- 北海道
- 青森県
- 岩手県
- 宮城県
- 秋田県
- 山形県
- 福島県
- 茨城県
- 栃木県
- 群馬県
@komagata
komagata / jquery.insert-at-caret.js
Created September 6, 2011 09:39
Insert string at caret.
(function($){
$.fn.insertAtCaret = function(v) {
var o = this.get(0);
o.focus();
if ($.browser.msie) {
var r = document.selection.createRange();
r.text = v;
r.select();
} else {
var s = o.value;
@komagata
komagata / symapps.rb
Created June 29, 2011 01:44
Make symlink from Mac GUI Apps.
#!/usr/bin/env ruby
require 'fileutils'
def e(path) path.gsub(/[ ()]/) {|s| "\\#{s}"} end
FileUtils.rm_rf("#{ENV['HOME']}/.macapp")
FileUtils.mkdir("#{ENV['HOME']}/.macapp")
Dir.glob('/Applications/{,Utilities/}*.app') do |path|
# coding: UTF-8
Earthquake.init do
output do |item|
`saykotoeri "#{item['user']['screen_name']}。#{item['text']}"`
end
end
@komagata
komagata / devise.ja.yml
Created February 18, 2011 02:46
Japanese locale file for devise.
ja:
errors:
messages:
not_found: "は見つかりませんでした。"
already_confirmed: "は既に登録済みです。"
not_locked: "はログイン可能です。"
devise:
failure:
unauthenticated: 'ログインしてください。'