Skip to content

Instantly share code, notes, and snippets.

@nazomikan
nazomikan / public_index.html
Created March 17, 2014 05:41
render in browser
<html>
<head>
<style type="text/css">
div {
width: 600px;
height: 50px;
}
.blue { background-color: blue; }
.green { background-color: green; }
@nazomikan
nazomikan / index.html
Created February 25, 2011 14:14
touch the number
<html>
<head>
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<style type="text/css">
#field td{
width:100px;
height:100px;
border:1px solid #333;
text-align:center;
}
@nazomikan
nazomikan / gist:845094
Created February 26, 2011 10:26
newつけ忘れ対策
function hoge() {
if (!(this instanceof hoge)) {
return new hoge();
}
//以下クラスの実装
}
@nazomikan
nazomikan / getElementsByClassName
Created October 10, 2011 07:09
indexOfの単語マッチを上手に使う(sliceはnodelistにかけるとieで例外を出すの別途対応が必要のはず)
document.getElementsByClassName = function (needle) {
var allNodes = document.getElementsByTagName('*'),
nodes = Array.prototype.slice.call(allNodes),
outArray = [],
i,c,l;
for (i = 0, l = nodes.length; i < l; i++) {
if (nodes[i].hasAttribute("class")) {
c = " " + nodes[i].className + " ";
if (c.indexOf(" " + needle + " ") !== -1) {
nazon.shuffle = function(ary) {
var i = ary.length, j, t;
while (i) {
j = Math.floor(Math.random() * i);
t = ary[--i];
ary[i] = ary[j];
ary[j] = t;
}
return ary;
}
@nazomikan
nazomikan / createQueryPattern.js
Created September 7, 2012 12:21
createQueryPattern
var urlPatterns = createQueryPattern('http://hogehoge/',[
'a=1',
'b=2',
'c=3',
'd=4',
'e=5',
'f=6'
]);
console.dir(urlPatterns);
@nazomikan
nazomikan / urlParser.js
Created September 7, 2012 20:31
Url Parser
/^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:¥?([^#]*))?(?:#(.*))?$/;
@nazomikan
nazomikan / gist:3670200
Created September 7, 2012 22:19
Strip subdomain
public static function stripSubdomain($domainb) {
$tlds = array('.com','.net','.org','.biz','.ws','.in','.me','.co','.co.uk','.org.uk','.ltd.uk',
'.plc.uk','.me.uk','.edu','.mil','.br.com','.cn.com','.eu.com','.hu.com','.no.com','.qc.com',
'.sa.com','.se.com','.se.net','.us.com','.uy.com','.ac','.co.ac','.gv.ac','.or.ac','.ac.ac',
'.af','.am','.as','.at','.ac.at','.co.at','.gv.at','.or.at','.asn.au','.com.au','.edu.au',
'.org.au','.net.au','.id.au','.be','.ac.be','.br','.adm.br','.adv.br','.am.br','.arq.br',
'.art.br','.bio.br','.cng.br','.cnt.br','.com.br','.ecn.br','.eng.br','.esp.br','.etc.br',
'.eti.br','.fm.br','.fot.br','.fst.br','.g12.br','.gov.br','.ind.br','.inf.br','.jor.br',
'.lel.br','.med.br','.mil.br','.net.br','.nom.br','.ntr.br','.odo.br','.org.br','.ppg.br',
@nazomikan
nazomikan / division.js
Created September 21, 2012 16:40
Processing division
(function () {
var queue;
queue = createQueue(0, 0, 100, 100, 25, function (xMin, yMin, xMax, yMax) {
var x, y;
for (x = xMin; x < xMax; x++) {
for (y = yMin; y < yMax; y++) {
// do someThing
}
}
});
@nazomikan
nazomikan / division.js
Created September 21, 2012 17:24
Processing division < javascript1.7
(function () {
var queue;
queue = createQueue(0, 0, 100, 100, 25, function (xMin, yMin, xMax, yMax) {
var x, y;
for (x = xMin; x < xMax; x++) {
for (y = yMin; y < yMax; y++) {
// do someThing
}
}
});