Skip to content

Instantly share code, notes, and snippets.

View zerobase's full-sized avatar

Hideto Ishibashi zerobase

View GitHub Profile
@zerobase
zerobase / morning-relay.jade
Last active August 29, 2015 14:17
Morning Relay by Shuntaro Tanigawa
html
title Morning Relay by Shuntaro Tanigawa
script(src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js")
body.world
#kamchatka.place
.person.guy.is-dreaming.giraffe
.clock
audio(src="alarm-kamchatka-boy.mp3").alarm
#mexico.place
.person.maiden.is-waiting(for="bus")
@zerobase
zerobase / booklog.rb
Created November 18, 2012 20:26
Booklog API (limit 100 items?)
require 'open-uri'
require 'json'
arg = ARGV.shift
if arg.nil?
print "usage: $0 username\n"
exit
end
username = arg.strip
api_url_fmt = "http://api.booklog.jp/json/%s?count=10000"
api_url = sprintf(api_url_fmt, username)
@zerobase
zerobase / gist:4602113
Last active December 11, 2015 12:38
What I learned on Scala: * Traits with a same private var name does not conflict. * Traits with a same method name do conflict.
/**
* Traits with a same private var name does not conflict.
* Traits with a same method name do conflict.
*/
trait Countable {
private var _count:Int = 0
def count:Int = _count
def countup:Unit = _count += 1
}
@zerobase
zerobase / webrick.rb
Last active December 15, 2015 02:09
Simple WEBrick Command. (My ruby version: ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-darwin12.2.0])
#!/usr/bin/env ruby
require 'webrick'
require 'optparse'
port = 8000
root = '.'
OptionParser.new do |opt|
opt.on('-p', '--port PORT', "default: #{port}") { |v| port = v }
@zerobase
zerobase / cleanUpDuplicatedFiles.rb
Last active December 17, 2015 17:09
To clean up duplicated files. For Mac OS X.
# For Mac OS X
# To clean up duplicated files.
# isDuplicate(fileName)
# It returns true is the files are duplicated.
# It tests:
# - a file name (before the extention) ends with [0-9], and
# - there is a same sized file without trailing [0-9] of its file name.
# For example: "Word Power Made Easy Norman Lewis 528p_067174190X 2.pdf"
# original: "Word Power Made Easy Norman Lewis 528p_067174190X.pdf"
@zerobase
zerobase / copy-and-paste-httpd.js
Last active December 20, 2015 08:59
A simple Node.js application which give you a secure way to copy & paste a short text between devices.
// A simple Node.js application which give you an easy insecure way to copy & paste a short text between devices.
//
// To use this app:
// 1. On your terminal, run: node copy-and-paste-httpd.js
// 2. Open http://ip-address-on-your-lan:port/ in your browser.
// 3. Paste any text and submit.
// 4. Open the same address from another device and you'll see the text.
// 5. Now you're done.
// 6. Don't forget to exit the process. It's insecure until you kill the process.
@zerobase
zerobase / https-proxy.js
Created September 9, 2013 10:20
[nodejitsu/node-http-proxy#Proxying to HTTP from HTTPS](https://github.com/nodejitsu/node-http-proxy#proxying-to-http-from-https)
var fs = require('fs'),
https = require('https'),
httpProxy = require('http-proxy');
var options = {
https: {
key: fs.readFileSync('path/to/your/key.pem', 'utf8'),
cert: fs.readFileSync('path/to/your/cert.pem', 'utf8')
},
target: {
###
# Factory Method Example in CoffeeScript
## Introduction
This example of the factory method pattern is a part of a [Tic-tac-toe](http://en.wikipedia.org/wiki/Tic-tac-toe) application. See [Wikipedia](http://en.wikipedia.org/wiki/File:Factory_Method_UML_class_diagram.svg) for the UML diagram of the factory method pattern.
This example has four classes: Grid, GridCell, Board and Space.
class FooView extends View
constructor: (@jquery, @model) ->
super @jquery, @model