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 "benchmark" | |
require "redis" | |
require "hiredis" | |
require "redis/connection/hiredis" | |
redis = Redis.new(timeout: 60) | |
redis.select(10) | |
if ARGV.include?("create") | |
puts "Creating feeds" |
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
# ID Generator for entities | |
# | |
# ## ID Generation | |
# It uses Twitter's Snowflake algorithm for ID generation. | |
# https://github.com/twitter/snowflake | |
# | |
# Our ID is an unsigned 64-bit integer that consists of four elements: | |
# | |
# - Timestamp: 41 bits, milliseconds from EPOCH_TIME | |
# - Shard ID: 12 bits, logical shard ID |
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 'formula' | |
class Phpbrew < Formula | |
head 'https://raw.github.com/c9s/phpbrew/master/phpbrew' | |
homepage 'https://github.com/c9s/phpbrew' | |
def install | |
system "chmod a+x phpbrew" | |
system "mkdir -p #{prefix}/bin" | |
system "cp phpbrew #{prefix}/bin" |
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
# -*- coding: utf-8 -*- | |
from itertools import repeat | |
foldr = lambda f, xs: reduce(lambda x, y: f(y, x), xs) | |
applyn = lambda f: lambda n, times: foldr(f, repeat(n, times)) | |
towerN = lambda n: pow if n == 1 else applyn(towerN(n - 1)) | |
tower1 = towerN(1) | |
tower2 = towerN(2) |
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
# -*- coding: utf-8 -*- | |
try: | |
import bisect | |
except: | |
pass | |
def main(): | |
(num_items, num_days) = map(int, raw_input().split()) | |
prices = sorted(int(raw_input()) for n in xrange(num_items)) |
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
module Resource { | |
export declare var html: { | |
[name: string]: string; | |
}; | |
export declare var css: { | |
[name: string]: string; | |
}; | |
var loadedCSS: { [name: string]: boolean } = {}; |
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/python | |
# -*- encoding: utf-8 -*- | |
""" | |
Password Generator for Mac OSX | |
Compatible with http://www.hashapass.com/ | |
""" | |
import sys | |
import os |
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
<?php | |
function benchmark_using_require_once() { | |
require_once 'b.php'; | |
B::noop(); | |
} | |
function benchmark_using_autoload() { | |
C::noop(); | |
} |
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
# INSTALL: | |
# alias up='source /path/to/up.sh' | |
# | |
# USAGE: | |
# $ up = cd .. | |
# $ up 2 = cd ../.. | |
# $ up 3 = cd ../../.. | |
# $ up foo = cd to the nearest `foo' directory in the ancestor path. | |
# ex) At /foo/bar/baz/ , then cd to /foo/ | |
# ex) At /foo/bar/foo/baz/ , then cd to /foo/bar/foo/ |
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/python | |
# | |
# Shell command for CotEditor | |
# | |
import sys | |
import os | |
import os.path | |
files = [os.path.abspath(s) for s in sys.argv[1:]] |