This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
# 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FooView extends View | |
constructor: (@jquery, @model) -> | |
super @jquery, @model |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>"compositionstart" and "compositionend" events, and Japanese Input Method</title> | |
</head> | |
<body> | |
<textarea name="textarea" id="textarea" cols="30" rows="3"></textarea> | |
<h2>onkeydown</h2> | |
<p>nowCompositioning: <span id="nowCompositioning"></span></p> | |
<p>keyCode: <span id="keyCode"></span></p> |
OlderNewer