Skip to content

Instantly share code, notes, and snippets.

View wozozo's full-sized avatar
😇
Hello

Yoichi Fujimoto wozozo

😇
Hello
  • Tokyo, Japan
  • 01:17 (UTC +09:00)
  • X @wozozo
View GitHub Profile
javascript:(function(d,r,i,n){n=d.createElement('div');n.setAttribute('style','position:fixed;width:100%;height:100%;left:0;top:0;opacity:.5;background:#000;z-index:9999');d.body.appendChild(n);n=d.createElement('div');n.setAttribute('style','position:fixed;left:50%;top:50%;width:10ex;height:1.2em;margin:-.5em 0 .5em -5ex;background:#fff;z-index:10000');d.body.appendChild(n);setInterval(function(){n.innerHTML=r[i=(i+1)%r.length];},100);})(document,["(´・ω・`)", "(・ω・` )", "(ω・` )", "(・` )", "(` )", "( )", "( ´)", "( ´・)", "( ´・ω)", "( ´・ω・)"],0);
@nijikokun
nijikokun / example-user.js
Created May 3, 2012 20:46
Beautiful Validation... Why have I never thought of this before?!
var user = {
validateCredentials: function (username, password) {
return (
(!(username += '') || username === '') ? { error: "No Username Given.", field: 'name' }
: (!(username += '') || password === '') ? { error: "No Password Given.", field: 'pass' }
: (username.length < 3) ? { error: "Username is less than 3 Characters.", field: 'name' }
: (password.length < 4) ? { error: "Password is less than 4 Characters.", field: 'pass' }
: (!/^([a-z0-9_-]+)$/i.test(username)) ? { error: "Username contains invalid characters.", field: 'name' }
: false
);
@moriyoshi
moriyoshi / gist:2417847
Created April 19, 2012 02:01
ツンパァードラグーン / ゲーム説明: あなたはパンティーが降ってきてドラゴンが襲ってくる空間に閉じ込められました。↑キーでジャンプしてドラゴンを避けながら←→キーで移動し素早くパンティーをゲットしてください。
javascript:(function(d,rd,im,w,h,xx,yy,l,s,f,r,j,t,dg,pt){im.src="data:image/gif;base64,R0lGODlh2AEIAIABAAAAAP///yH5BAEKAAEALAAAAADYAQgAAAL+jI+py+0PYopA0SlD1Wjv11xYR31lZojnp6lrKsIxSNf2Eb+4m59yubugJLrRsILaKY8/j6/ZNPWAraW0CsNWM9zizbJifWmzltiMuY7GuGxQ6Yb/4qT11hRPsvc2ohPehRVoV1eopVc3iCjk98f0eAVJlySZBYnkRyfzFcYxwVdz5mmxIEVZ1qemuSl3F7VaqJInClprl2l5VmnYOtubiPnbCYTrmmuFXMqymxlspiiGCuKRMkptG6JLuxjZPcbUSzUnKNpYdooujY196QJmNeWO1gmbewrmM+x9zM9zL9doXpEZ4lhx+oRn1DpCHBBpsfTqmUMH4CapM4eqWEWoTwXrLQSlL5mhYsL2HaJ1p8e7YOZOSnTE6KIqlxKjOCEYbSKZNhyvfeTF890nmy9RZqs2Us9GciI3Lsv58yezP8YGAXWjcaYkeUnJOTMWCyZVmr4MxhSoVWeoIVijDu2gMGibmy+8rH1KTMeTpPGepjmi1u23bgWp7A2pjBG8vlgxZqX5xCExr1DCdfTLj2xRdmcFT5L70FrPNKE9mz6NOrXq1axbgyoAADs=";yy=h-8;im.onload=function(n,c,di,k,z){n=d.createElement("canvas");n.width=w;n.height=h;n.setAttribute("style","background-color:#ffe;width:512px;height:512px;position:absolute;left:0;top:0");d.body.appendChild(n);d.onkeydown=function(e){k=e.which;return false};d.onkeyup=function(e){k=0};c=n.getContext("2d");funct
import urlparse
import lxml.html as html
import sys
import json
BLOG_URL = 'http://torufurukawa.blogspot.jp/'
def fetch(url):
print >>sys.stderr, 'fetcing %s...' % url
retry_count = 0
@garaemon
garaemon / gist:2232015
Created March 29, 2012 01:00
UtilityMacros.h
#define DICT(...) ([NSDictionary dictionaryWithObjectsAndKeys:__VA_ARGS__, nil])
#define MDICT(...) ([NSMutableDictionary dictionaryWithObjectsAndKeys:__VA_ARGS__, nil])
#define FORMAT(...) ([NSString stringWithFormat:__VA_ARGS__])
#define ARRAY(...) ([[NSArray alloc] initWithObjects:__VA_ARGS__, nil])
#define MARRAY(...) ([[NSMutableArray alloc] initWithObjects:__VA_ARGS__, nil])
#define ASSOC(D, K) ([D objectForKey:K])
#define PREDICATE(F, ...) ([NSPredicate predicateWithFormat:F, __VA_ARGS__])
#define LOCALIZED_STRING(S) (NSLocalizedString(S, S))
#define IS_VALID_STRING(s) (s && s != NULL && ![s isEqual:[NSNull null]])
#define CG_RECT_MAKE_SHORT(N) (CGRectMake(N##_X, N##_Y, N##_WIDTH, N##_HEIGHT))
> perl -E 'say "生" & "死"'
生 Life U+751F \xe7\x94\x9f 11100111 10010100 10011111
死 Death U+6B7B \xe6\xad\xbb 11100110 10101101 10111011
愛 Love u+611B \xe6\x84\x9b 11100110 10000100 10011011
@ku
ku / gopen
Created February 17, 2012 22:23
open corresponding URL of the repository of current directory
#!/bin/sh
GIT='git'
if test `uname` = "Darwin" ; then
SED_OPT='-E'
OPEN='open'
else
SED_OPT='-r'
OPEN=''
@oyakata
oyakata / README.rst
Created February 16, 2012 07:17
pytestをちょっと試した

pytest

Installation and execution

$ pip install pytest

$ py.test test_foo.py

@riywo
riywo / os_type
Created January 7, 2012 04:52
OSのタイプをなんとなく出力
#!/bin/sh
if [ $OSTYPE = "linux-gnu" ]; then
LSB_ID=`lsb_release -i | cut -f2 -d:`
LSB_VERSION=`lsb_release -r | cut -f2 -d:`
OS_VERSION=`echo $LSB_ID-$LSB_VERSION | sed -e "s/ //g"`
MACHINE_TYPE=`uname -m`
echo $OS_VERSION-$MACHINE_TYPE
else
echo `uname -rsm | sed -e "s/ /-/g"`
fi
function declitimg(img) {
var cv = document.createElement('canvas');
cv.width = img.width;
cv.height = img.height;
var ctx = cv.getContext('2d');
ctx.drawImage(img, 0, 0);
var imd = ctx.getImageData(0, 0, img.width, img.height);
var s = '';
for (var i = 0; i < imd.data.length && imd.data[i] !== 0;) {
var c1 = imd.data[i++];