Skip to content

Instantly share code, notes, and snippets.

View chsh's full-sized avatar
👍
Love your code.

CHIKURA Shinsaku chsh

👍
Love your code.
View GitHub Profile
@chsh
chsh / ean.swift
Created January 29, 2015 14:45
Calc EAN for Swift
//
// EAN.swift
//
import Foundation
class EAN {
class func isValid(ean: String) -> Bool {
return EAN().isValid(ean)
}
@chsh
chsh / simple-jquery-example.js
Created January 23, 2015 14:31
Simple JavaScript module definition using jQuery.
// usage: call $.foobaa.initialize();
(function($) {
var hoge;
var moge;
var register_click_actions = function() {
$(hoge).show();
};
@chsh
chsh / paas.rb
Created January 23, 2015 03:44
Convert "PaaS" to "paas", "paas" to "PaaS" well.
ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.acronym 'PaaS'
end
@chsh
chsh / pg_pub_sub.rb
Last active April 27, 2026 19:17
PostgreSQL LISTEN/NOTIFY example for ruby
#
# A:
# pubsub = PgPubSub.new('channelname')
# pubsub.subscribe do |data|
# puts "data: #{data} is coming!"
# end
#
# B:
# pubsub = PgPubSub.new('channelname')
# pubsub.publish("hello world")
@chsh
chsh / run_bg.swift
Created December 31, 2014 08:34
Run NSTask in background for Swift
var taskQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0)
dispatch_async(taskQueue, { () -> Void in
let task = NSTask()
task.launchPath = "/bin/ls"
task.arguments = []
let pipe = NSPipe()
task.standardOutput = pipe
task.launch()
let data = pipe.fileHandleForReading.readDataToEndOfFile()
var dataString = NSString(data: data, encoding: NSUTF8StringEncoding)
@chsh
chsh / link_string.swift
Created December 28, 2014 17:16
Show link text on NSTextField for OS X by swift.
@chsh
chsh / koala.rb
Created December 10, 2014 03:04
Koala configuration to support Facebook API 2.0
Koala.config.api_version = 'v2.0'
@chsh
chsh / add-carrierwave.md
Created November 30, 2014 04:18
Add carrierwave integration.

open Gemfile

add gem ‘carrierwave’

bundle
rails g uploader Image
rails g migration add_image_to_product image:string
rake db:migrate
@chsh
chsh / item-list.md
Created October 31, 2014 15:18
持ち物リスト

河村さん

  • 地藏さん名刺
  • バーコードリーダ × 2
  • 付箋 (カフェで使っているやつ)
  • Mac x 1

チクラ

  • バーコードリーダー x 1
  • Mac x 1
@chsh
chsh / path.rb
Created October 24, 2014 03:00
simple deep hash scanner
# hash = { a: { b: 1 } }
# path hash, :a, :b -> 1
def path(source, *keys)
return nil unless source
return nil unless source.respond_to? :[]
keys.each do |key|
return nil unless source.respond_to? :[]
source = source[key]