Skip to content

Instantly share code, notes, and snippets.

Kota Saito kotas

Block or report user

Report or block kotas

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kotas
kotas / benchmark.rb
Created Jul 9, 2014
Timeline using Redis sorted set
View benchmark.rb
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"
View id_generator.rb
# 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
View phpbrew.rb
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"
View tetration.py
# -*- 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)
View ec_campaign.py
# -*- 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))
View resource.ts
module Resource {
export declare var html: {
[name: string]: string;
};
export declare var css: {
[name: string]: string;
};
var loadedCSS: { [name: string]: boolean } = {};
@kotas
kotas / genpass.py
Created Jan 4, 2012
Password Generator for Mac OSX
View genpass.py
#!/usr/bin/python
# -*- encoding: utf-8 -*-
"""
Password Generator for Mac OSX
Compatible with http://www.hashapass.com/
"""
import sys
import os
@kotas
kotas / a.php
Created Feb 8, 2011
require_once vs autoload
View a.php
<?php
function benchmark_using_require_once() {
require_once 'b.php';
B::noop();
}
function benchmark_using_autoload() {
C::noop();
}
@kotas
kotas / up.sh
Created Feb 3, 2011
cd up-forward
View up.sh
# 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/
@kotas
kotas / gist:580871
Created Sep 15, 2010
CotEditor をシェルから起動するの
View gist:580871
#!/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:]]
You can’t perform that action at this time.