Skip to content

Instantly share code, notes, and snippets.

View tiye's full-sized avatar
💭
Make Cirru great again!

题叶 tiye

💭
Make Cirru great again!
View GitHub Profile
@tiye
tiye / paint,js
Created July 12, 2012 12:11
几行代码网页变成画布
document.body.innerHTML = "<canvas id='cvs' width='1200px' height='600px'></canvas>";
cvs = document.getElementById('cvs');
ctx = cvs.getContext('2d');
cvs.onmousedown = function(){
cvs.onmousemove = function(e){ctx.fillRect(e.offsetX,e.offsetY,2,2);console.log(e.clientX);}
};
cvs.onmouseup = function(){ cvs.onmousemove =function(e){}};
@tiye
tiye / curry-object.coffee
Created July 22, 2012 13:19
curry 函数读取 object
a =
d: 2
b: '3'
c:
a: 'd'
f: 4
a:
a:
a:
@tiye
tiye / pics.md
Created July 26, 2012 19:47
无关之人

@tiye
tiye / guil.coffee
Created August 8, 2012 11:03
sheme with less brackets
#!/usr/bin/coffee
n = (str) -> (str.match /^\s*/)[0].length
add_left = (str, x) ->
x /= 2
left = n str
[1..x].forEach ->
str = str[...left] + '(' + str[left..]
str
@tiye
tiye / index.html
Created August 9, 2012 01:34
play a mp3 file with buzz continously (need Chrome and buzz, audio API)
<html><head><title>Player</title><script src="buzz.js"></script>
<!-- should download "buzz.js" fisrt from "http://buzz.jaysalvat.com/"-->
<script type="text/javascript">
(function() {
var timer;
window.my = new buzz.sound('xiao.mp3');
my.play().loop();
@tiye
tiye / w-demo-fake.coffee
Created August 14, 2012 14:47
comparation
compareAsync = (x, y) ->
sleep 10 # 暂停10毫秒
x - y
swapAsync = (a, i, j) ->
sleep 20 # 暂停20毫秒
t = a[i]
a[i] = a[j]
a[j] = t
paint a # 重绘数组
@tiye
tiye / demo.coffee
Created September 1, 2012 10:51
OO is strange...
obj = require('./fake').obj
global.show = console.log
show (obj 'f1', 'xx')
show (obj 'f2', 'qq')
show (obj 'f3', 'ss')
obj '.set', 'f3', (x) -> 'this is f3 ' + x
show (obj 'f3', 'ss')
obj2 = (obj '.clone', 'xx')
@tiye
tiye / bubble-sert.sp
Created September 4, 2012 07:23
Scirpus fabonacci demo
= a (# 1 24 53 45 3 4 56 578 89 56 56)
= sort
-> (start end list)
if (>= end a.length) (<- list)
if (>= start end)
<- (sort 0 (+ end 1) list)
do
= small (. list start)
= big (. list (+ start 1))
if (> small big)
@tiye
tiye / file.txt
Created September 8, 2012 10:28
bad markHTML
<a>
<a>
<a>
<a>
<a>
<a>
<a>
<a>
<a>
@tiye
tiye / .bashrc
Created September 10, 2012 03:15
new to arch
#
# ~/.bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
alias ls='ls --color=auto'
PS1='[\u@\h \W]\$ '