Skip to content

Instantly share code, notes, and snippets.

View kt3k's full-sized avatar

Yoshiya Hinosawa kt3k

View GitHub Profile
@kt3k
kt3k / combinators.coffee
Created April 14, 2013 11:18
Implementation of combinators in CoffeeScript is very natural!
S = (X) -> (Y) -> (x) -> X(x)(Y(x))
K = (X) -> (x) -> X
I = (x) -> x
Y = (f) -> ((x) -> f(x(x)))((x) -> f(x(x)))
@kt3k
kt3k / div.algo
Created April 20, 2013 06:39
div implementation in ALGOL60
integer procedure div(a, b); value a, b;
integer a, b;
if b = 0 then
fault( `div by zero' , a)
else
begin integer q, r;
q := 0; r := iabs(a);
for r := r - iabs(b) while r ≥ 0 do q := q + 1;
div := if a < 0 ≡ b > 0 then -q else q
end div;
@kt3k
kt3k / alert.js
Created April 20, 2013 10:27
obfuscated alerts;
Function.apply.call(Function.call.apply, alert, [window, ['a']]);
Function.apply.call.apply(Function.call.apply.call, [alert, function(){}(), 'a']);
@kt3k
kt3k / cutRoundedRect.js
Created May 12, 2013 12:11
cutting out rounded rectangle.
var cutRoundedRect = function(ctx, radius, x, y, w, h) {
var left = x;
var top = y;
var right = x + w;
var bottom = y + h;
ctx.globalCompositeOperation = 'destination-in';
ctx.fillStyle = 'black';
ctx.beginPath();
@kt3k
kt3k / setsumei.md
Created July 28, 2013 10:58
grunt-contrib-jasmine + travis-ci + coveralls.io

jscoverage で instrumented version の src tree を作る

jscoverage src src-cov

instrumentation の command を grunt 化する (grunt-shell を使うと便利)

shell:
@kt3k
kt3k / gist:6221753
Created August 13, 2013 14:37
groovy test
kt3k:groovy kt3k$ cat test2.groovy
println 'a'*2
kt3k:groovy kt3k$ groovy test2.groovy
aa
kt3k:groovy kt3k$ cat test.groovy
println 2*'a'
kt3k:groovy kt3k$ groovy test.groovy
Caught: groovy.lang.MissingMethodException: No signature of method: java.lang.Integer.multiply() is applicable for argument types: (java.lang.String) values: [a]
Possible solutions: multiply(java.lang.Number), multiply(java.lang.Character)
groovy.lang.MissingMethodException: No signature of method: java.lang.Integer.multiply() is applicable for argument types: (java.lang.String) values: [a]
@kt3k
kt3k / easytether-on-off
Created August 14, 2013 04:23
AppleScript to turn on and off the EasyTether extension.
set state to do shell script "kextstat | grep EasyTether | cat"
if state is "" then
display dialog "turning on EasyTether"
do shell script "kextload /System/Library/Extensions/EasyTetherUSBEthernet.kext/" with administrator privileges
else
display dialog "turning off EasyTether"
do shell script "kextunload /System/Library/Extensions/EasyTetherUSBEthernet.kext/" with administrator privileges
end if
@kt3k
kt3k / test.py
Last active December 23, 2015 19:29
test script
#!/usr/bin/env python
print 'test'
# abc
@kt3k
kt3k / test.php
Created September 24, 2013 10:15
test script
#! /usr/bin/env php
<?php
echo 123;