Skip to content

Instantly share code, notes, and snippets.

View shelling's full-sized avatar

shelling shelling

View GitHub Profile
def anagram?(s1, s2)
hash = Hash.new(0)
s1.each_char do |c|
hash[c] += 1
end
s2.each_char do |c|
hash[c] -= 1
end
hash.values.uniq == [0]
end
# Project Euler 26
def recurring(number)
remainders = Hash.new(0)
value = 1
position = 0
length = 0
while value != 0 && remainders[value] == 0
remainders[value] = position
@shelling
shelling / tsn.srt
Created March 5, 2011 08:05
The Social Network subtitle
1
00:00:04,829 --> 00:00:09,829
Credit to: Sakti Tandi [1st Indonesian-Script]
English. Subs. and. Re-Sync. by npdv-iD
2
00:00:19,043 --> 00:00:21,168
You know there are more people
with genius IQ living in China
#include <stdio.h>
#include <stdlib.h>
#include <hdf5.h>
double **
Plain_init(int x, int y) {
double **plain = malloc(sizeof(double*)*x);
double *space = malloc(sizeof(double)*x*y);
for (int i = 0; i < x; i++) {
plain[i] = space + i * y;
本對照表已經移到 https://github.com/g0v/tisa-map/blob/master/pod/cpc%3C-%3Estd.txt
請至該處取得新版本
--------------------------------------------------------------------------------
CPC841 | 6201電腦軟體設計業
CPC842 |
CPC843 | 6202電腦系統整合服務業
CPC844 | 6209其他電腦系統設計服務業
CPC845+849 | 6312資料處理、網站代管及相關服務
--------------------------------------------------------------------------------
CPC83104** | 7729其他運輸工具設備租賃業
class Numeric
Q = ["B", "K", "M", "G", "T", "P", "Z"]
def humanize
index = ( (Math.log(self)/Math.log(10-10**-12)).to_i / 3 ).to_i # to_i to round down
return [ self/10.0**(index*3), Q[index] ].join
end
end
Makefile
*.o
*.so
mkmf.log
a.out
grammar Foo
rule top
value? {
def to_ruby
elements.to_ruby
end
}
end
rule value
array / object / primitive
#!/usr/bin/env ruby
$:.unshift(".")
require "treetop"
require "lisp"
require "pp"
pp LispParser.new.parse("1.1").calculate
pp LispParser.new.parse("( )").calculate
pp LispParser.new.parse("(+)").calculate
pp LispParser.new.parse("(-)").calculate