Skip to content

Instantly share code, notes, and snippets.

View zerobase's full-sized avatar

Hideto Ishibashi zerobase

View GitHub Profile
@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 / 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 / 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 / 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 / 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)