Skip to content

Instantly share code, notes, and snippets.

View iahu's full-sized avatar
🌴
On vacation

i18u iahu

🌴
On vacation
View GitHub Profile
@iahu
iahu / Gtlaz.markdown
Created March 24, 2014 09:41
A Pen by fusionBin.
@iahu
iahu / hoverHint.css
Created March 26, 2014 02:12
hoverHint
.hint {position:absolute;font:12px arial, 宋体;background:#2d2d2d;color:#f2f2f2;padding:6px 9px;border:1px solid #000;z-index: 999;margin-top:0.5em;}
.hint-content {position: relative;z-index: 1000;}
.hint i, .hint em {position: absolute;display: block;height: 0;width: 0;background: transparent;border: 6px solid transparent;z-index: 100;border-bottom-color: #000;top: -1em;left: 50%;margin-left: -0.5em;}
.hint i {border-bottom-color: #2d2d2d;z-index: 101;margin-top: 1px;}
@iahu
iahu / a2c.js
Created September 26, 2014 02:56
阿拉伯数字转中文数字
function toChineseNumeral(num){
var numerals = {
'-':'负',
'.':'点',
0:'零',
1:'一',
2:'二',
3:'三',
4:'四',
5:'五',
@iahu
iahu / Befunge.js
Created September 26, 2014 02:58
jsBefunge
function Befunge(code) {
var output = '';
var stack = [];
var codeArray = code.split('\n');
var x = 0;
var y = 0;
var d = code.charAt(0);
var next = d;
var cmd = 'NORMAL';
var loop = true;
@iahu
iahu / maybe.js
Created September 26, 2014 03:00
a Maybe Monad
function Maybe() {
Object.freeze(this);
}
function Just (x) {
this.toString = function () { return "Just " + x.toString(); };
this.just = x;
Object.freeze(this);
}
Just.prototype = new Maybe();
@iahu
iahu / UriBuilder.js
Created September 26, 2014 03:02
a js URI tool
function UriBuilder(uri) {
this.uri = uri;
this.parse();
return this;
}
UriBuilder.prototype.parse = function() {
// var match = this.uri.match(/(\w+:\/\/?.+?\..+\..+)?(\?.+)/);
var match = this.uri.split('?');
var params, o = {},t;
@iahu
iahu / GeneticAlgorithm
Created September 29, 2014 09:45
Genetic Algorithm
var GeneticAlgorithm = function () {};
GeneticAlgorithm.prototype.generate = function(length) {
var s = '';
while (length--) {
s += ~~(Math.random()+0.5);
}
return s;
};
@iahu
iahu / functionList.js
Created September 29, 2014 09:50
Singly-linked lists
function List() {}
function EmptyList() {}
EmptyList.prototype = new List();
EmptyList.prototype.constructor = EmptyList;
EmptyList.prototype.toString = function() { return '()'; };
EmptyList.prototype.isEmpty = function() { return true; };
EmptyList.prototype.length = function() { return 0; };
EmptyList.prototype.push = function(x) { return new ListNode(x, this); };
@iahu
iahu / index.html
Last active August 29, 2015 14:18
window.name跨域小例
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body {padding:0 20px;margin: 0;font-family: '黑体', sans-serif;}
code {border: 1px solid #e3e3e3;padding: 1px 2px;}
#res {height: 5em;border: 1px solid #999;}
</style>
@iahu
iahu / uninstall.sh
Created April 29, 2015 02:49
OSX 10.10 uninstall VMsvga2_v1.2.5
#!/bin/bash
SLE=/System/Library/Extensions
RM=/bin/rm
PKGUTIL=/usr/sbin/pkgutil
TOUCH=/usr/bin/touch
if (( $UID != 0 )); then
echo This script must be run as root, try \'sudo $0\'
exit 1