Skip to content

Instantly share code, notes, and snippets.

Avatar
🌴
On vacation

i18u iahu

🌴
On vacation
View GitHub Profile
View hoverHint.css
.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 Sep 26, 2014
阿拉伯数字转中文数字
View a2c.js
function toChineseNumeral(num){
var numerals = {
'-':'负',
'.':'点',
0:'零',
1:'一',
2:'二',
3:'三',
4:'四',
5:'五',
View Befunge.js
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 Sep 26, 2014
a Maybe Monad
View maybe.js
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();
View UriBuilder.js
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 / functionList.js
Created Sep 29, 2014
Singly-linked lists
View functionList.js
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 / GeneticAlgorithm
Created Sep 29, 2014
Genetic Algorithm
View GeneticAlgorithm
var GeneticAlgorithm = function () {};
GeneticAlgorithm.prototype.generate = function(length) {
var s = '';
while (length--) {
s += ~~(Math.random()+0.5);
}
return s;
};
@iahu
iahu / index.html
Last active Aug 29, 2015
window.name跨域小例
View index.html
<!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 Apr 29, 2015
OSX 10.10 uninstall VMsvga2_v1.2.5
View uninstall.sh
#!/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