Skip to content

Instantly share code, notes, and snippets.

View masahitojp's full-sized avatar
🎯
Focusing

Masato Nakamura masahitojp

🎯
Focusing
View GitHub Profile
@masahitojp
masahitojp / gist:787539
Created January 20, 2011 07:41
初めてのマクロ(unless)
; unless macro
(define-syntax unless
(syntax-rules ()
((_ pred b1 ...)
(if (not pred) (begin b1 ...)))))
; 動作テスト
(let ((i 0))
(unless (= i 1)
(display "i != 0")
@masahitojp
masahitojp / gist:794785
Created January 25, 2011 10:51
example of Proseccing.js
<doctype html>
<html>
<head>
<script src="processing-1.0.0.min.js"></script>
<script type="application/javascript">
/*
* This code searches for all the <script type="application/processing" target="canvasid">
* in your page and loads each script in the target canvas with the proper id.
@masahitojp
masahitojp / gist:796574
Created January 26, 2011 11:16
時間計測(試用版)
runTime=function(func){
var before = (new Date()).getTime();
func();
return ((new Date()).getTime() - before);
}
function heikin(arr){
var sum=0;
var n = arr.length;
for (var i =0; i < n; i++) sum += arr[i];
@masahitojp
masahitojp / gist:803672
Created January 31, 2011 05:22
"new Function" is different from eval
var a = 1;
(function(num){
var a = 10;
// function literal
//var f = function(b){return a + b;};
// eval
//eval("var f = function(b){return a + b;}");
@masahitojp
masahitojp / jquery.smarthistory.js
Created February 23, 2011 10:44 — forked from hokaccha/jquery.smarthistory.js
change window.addEventListener() To this.bind()[jQuery evnent add ]
/*
* jquery.smarthistory.js
*
* Copyright (c) 2010 Kazuhito Hokamura
* Licensed under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
* @author Kazuhito Hokamura (http://webtech-walker.com/)
* @version 0.0.1
*
@masahitojp
masahitojp / gist:863593
Created March 10, 2011 05:00
Python で凄く簡単に GET/POST 送信ができる関数を作りました(ry
# -*- coding: utf-8 -*-
import urllib
import time
def wbs_request(method_string, url, args={}):
params = urllib.urlencode(args)
method = method_string.lower()
if method == ':get':
resp = urllib.urlopen( "%s?%s" % (url, params) )
[buildout]
parts = pq
[pq]
recipe = z3c.recipe.scripts
eggs = pyquery
interpreter=py
[buildout]
parts = demo
[demo]
recipe = zc.recipe.egg
eggs = docutils
pygments
sphinx
rstspreadsheet
interpreter = py
@masahitojp
masahitojp / sleep_sort.py
Created May 20, 2011 04:10
Python でsleep_sort
#!/usr/bin/env python
# coding: utf-8
from multiprocessing import cpu_count, Process, Queue
from os import getpid
from time import sleep
from random import randint
def put_queue(queue, num):
sleep(num)
queue.put(num)
// 今開いてるページに変更があったらリロード
var ypos = location.hash.replace(/^[#]/,"");
(!!ypos && (typeof ypos === "number"))&&window.scroll(0,ypos);
setInterval(function(){
var self = arguments.callee;
var req = new XMLHttpRequest;
req.open("GET",location.href,true);
req.onload = function(){