Skip to content

Instantly share code, notes, and snippets.

@wakhub
wakhub / gist:2392872
Created April 15, 2012 13:44
Append jQuery & jQuery UI Bookmarklet
javascript:(function(){var u='https://ajax.googleapis.com/ajax/libs/',d=document,s=d.createElement('script'),s2=s.cloneNode();s.src=u+'jquery/1.7.2/jquery.min.js';s2.src=u+'jqueryui/1.8.18/jquery-ui.min.js';d.head.appendChild(s);d.head.appendChild(s2)})();
@wakhub
wakhub / fib.c
Created April 26, 2012 15:16
C and konoha fibonacci
#include <stdio.h>
int fib(int n) {
if (n <= 1) {
return n;
}
return fib(n - 1) + fib(n - 2);
}
int main(){
@wakhub
wakhub / polyglot.pl.php.py.rb
Created April 28, 2012 16:32
PHP and Perl and Python/Ruby polyglot
#<?php eval('echo "PHP Code\n";'); __halt_compiler(); ?>
print ((("b" + "0" == 0) and eval('"Perl Code\n"')) or (0 and "Ruby Code\n" or "Python Code"));
__DATA__ = 1
"""""
__END__
===== This is comment of all. =====
@wakhub
wakhub / liger_and_tigon.py
Created May 26, 2012 15:30
Liger and Tigon
import random
class Female(object): pass
class Male(object): pass
def get_sex():
return [Female, Male][random.randint(0, 1)]
class Animal(object):
@wakhub
wakhub / polyglot.pl.php.py.rb.cpp.m
Created June 8, 2012 13:58 — forked from SaswatPadhi/polyglot.pl.php.py.rb.cpp
PHP + Perl + Python + Ruby + C + C++ + Objective-C - polyglot
#/*<?php echo "PHP Code\n"; __halt_compiler();?> */
#include <stdio.h> /*
print (("b" + "0" == 0 and "Perl Code\n") or (0 and "Ruby Code\n" or "Python Code"));
__DATA__ = 1
"""""
__END__
@wakhub
wakhub / Scala.scala
Created July 15, 2012 05:35
JavaScript Hoisting Test
var a = 0;
def f() = {
if (false) {
var a = 456;
}
println(a);
}
def f2() = {
@wakhub
wakhub / gist:3236540
Created August 2, 2012 12:01
勘違いに関するメモ

ミームにおける突然変異のようなもの

竹内関数

ジョン・マッカーシーは竹内関数を記憶違いで[2] z を返すように変更し、これがTak関数として広まった。...

なぜλ計算はλ計算と呼ばれているのか

しかしチャーチの文章を出版するとき、当時の印刷技術ではハット付きの文字が印刷できなかった (!) ので、 ^x.2x+1
@wakhub
wakhub / goodparts.js
Created August 3, 2012 14:35
Scripting Language: The Good Parts
var f = function(){
console.log('a')
};
f.foo = function(){
console.log('b');
};
f.foo.bar = function(){
console.log('c');
};
f.foo.baz = function(){
@wakhub
wakhub / quote.js
Created August 11, 2012 01:52
Quote Bookmarklet
// javascript:(function(js,d,s){d=document,s=function(src,sc,date){sc=d.createElement('script');sc.setAttribute('src',src);d.body.appendChild(sc);};date=(new Date()).getTime();s(js+'?'+date);})('//raw.github.com/gist/3319875/quote.js');
(function(){
var d = document,
t = d.getElementById('_____blockQuote');
if (!t) {
t = d.createElement('textarea');
t.setAttribute('id', '_____blockQuote');
d.body.appendChild(t);
}
with (t.style) {
@wakhub
wakhub / gist:3732400
Created September 16, 2012 13:11
Prototype based OOP in Python
import new
class ProtoObj(object):
def __init__(self, prototype={}):
self.prototype = prototype
self.__super_prototype = {}
def clone(self):
Obj = new.classobj('ProtoObjClone', (ProtoObj, ), {})