Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
from PIL import Image
from math import sqrt
from numpy.fft import rfft
from collections import Counter
def computeContinuityScore(image, x1, x2):
width, height = image.size
data = image.getdata()
# CoffeeScript version 1.1.2
# compiles
if 'foo' ==
String.fromCharCode.apply(null,
[102, 111, 111])
alert 'foo!!'
# doesn't compile
if 'foo' ==
package extensions;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
@edvakf
edvakf / sjis.js
Created September 25, 2011 09:14
function sjisArrayToString(ary) {
var res = [];
for (var i = 0, code; code = ary[i++]; ) {
if (single_byte.hasOwnProperty(code)) {
res.push(single_byte[code]);
} else {
code = (code << 8) + ary[i++];
if (double_byte.hasOwnProperty(code)) {
res.push(double_byte[code]);
} else {
@edvakf
edvakf / bookmarklet.js
Created August 24, 2011 17:50
Opera's bug, xpath "text()" returns non-text elements
javascript:(function(){
var x=document.evaluate('//body//text()',document,null,7,null);
for(var i=0,l=x.snapshotLength,e;e=x.snapshotItem(i++);i<l)
if(e.nodeType!==3)
console.log(e)
})()
// => [object HTMLDivElement]
//http://www.montrealgazette.com/Canadian+wireless+startup+takes+maverick+approach/5300364/story.html
// ==UserScript==
// @name fldr_show_fc2_images.user.js
// @namespace http://d.hatena.ne.jp/os0x/
// @description Make fc2 images viewable on LDR/Fastladder
// @include http://reader.livedoor.com/reader/
// @include http://reader.livedoor.com/public/*
// @include http://fastladder.com/reader/
// ==/UserScript==
// via http://gist.github.com/48621
@edvakf
edvakf / shorten_url.js
Created June 1, 2011 03:35
twicli の shorten_url.js 改変
/* assist inline URL shortening in the text area */
(function(){
var wait = 5000; // time to wait before deciding that the server is unreacheable
var _updateCount = window.updateCount;
var fst = $('fst');
var timer, ele, command, original;
var remove = function(e){if(e && e.parentNode)e.parentNode.removeChild(e); e = null};
var api = 'http://atsushaa.appspot.com/shorten/get';
var cache = {};
@edvakf
edvakf / nico-tumblr.js
Created May 26, 2011 07:48
ニコニコ動画から Tumblr に投稿するブックマークレット改変
/*
http://d.hatena.ne.jp/takeken/20091113/1258104204
これの改変バージョン。
ニコニコ動画の外部プレーヤー用のスクリプトは document.write を使ってるのでどうしても同期じゃないといけない。
そこで、iframe を作ってその中でニコニコ動画のスクリプトを読み込んでいる。
*/
javascript:(function(){var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='http://www.tumblr.com/share',l=d.location,e=encodeURIComponent;if(/nicovideo.jp/.test(l.host)){var n=location.href.match(/.*([ns]m[0-9]\d+)/)[1];k=Date.now();s='<a href="http://www.nicovideo.jp/watch/'+n+'">'+document.title+'<noscript><br><img width="300" src="http://tn-skr'+((Math.random()*4|0)+1)+'.smilevideo.jp/smile?i='+n.slice(2)+'"></noscript></a><script id="nicovideo_'+k+'">(function(d,s,v,f){f=d.createElement("iframe");f.style.border="none";f.height=385;f.width=485;v=d.getElementById(v);v.parentNode.insertBefore(f,v);f.contentDocument.write("<!DOCTYPE html><head><style>*{margin:0;padding:0;}body *{display:block}<\\/style><\\/head><body><scr"+"ipt src="+s+"><\\/scr"+"ipt><\\/body>")}(document,
var bigint;
// very very basic bigint class.
// complete version: https://github.com/dankogai/js-math-bigint
(function() {
// Original: http://www.onicos.com/staff/iz/amuse/javascript/expert/BigInt.txt
//
// BigInt.js - Arbitrary size integer math package for JavaScript
// Copyright (C) 2000 Masanao Izumo <iz@onicos.co.jp>
javascript:var div=document.createElement('div');div.style='position:fixed;left:0;top:0;height:100px;width:100px;background-color:red';document.body.appendChild(div);document.querySelector('#pnnext').click();