Skip to content

Instantly share code, notes, and snippets.

View wozozo's full-sized avatar
😇
Hello

wozozo

😇
Hello
  • Tokyo, Japan
View GitHub Profile
@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=''
> 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
@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))
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
@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
@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
);
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);
@sigilioso
sigilioso / cuter.py
Created June 19, 2012 22:58
Python PIL Example: get a thumbnail by resizing and cropping an image.
# -*- coding: utf-8 -*-
import Image
def resize_and_crop(img_path, modified_path, size, crop_type='top'):
"""
Resize and crop an image to fit the specified size.
args:
img_path: path for the image to resize.
@hail2u
hail2u / test.scss
Last active October 6, 2015 07:28
レスポンシブフォwww
@mixin optimize-font-size($sizes) {
@each $r in $sizes {
$w: $safe-for-full * $r * $r;
@media (min-width: $w) {
font-size: percentage($r);
}
}
}
@hail2u
hail2u / cf-email-croaking.html
Created June 20, 2012 09:11
CloudFlareのメールアドレスクローキング
<p>
<a href="http://cloudflare.com/email-protection.html#bcd7c5d3fcd4ddd5d08ec992d2d9c8">
<span id="__cf_email__" class="4c2735230c242d25207e3962222938">
[email&nbsp;protected]
</span>
<script type="text/javascript">
/* <![CDATA[ */
(function () {
try {
var s, a, i, j, r, c, l = document.getElementById("__cf_email__");