This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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){}}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| a = | |
| d: 2 | |
| b: '3' | |
| c: | |
| a: 'd' | |
| f: 4 | |
| a: | |
| a: | |
| a: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 # 重绘数组 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| = 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <a> | |
| <a> | |
| <a> | |
| <a> | |
| <a> | |
| <a> | |
| <a> | |
| <a> | |
| <a> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # ~/.bashrc | |
| # | |
| # If not running interactively, don't do anything | |
| [[ $- != *i* ]] && return | |
| alias ls='ls --color=auto' | |
| PS1='[\u@\h \W]\$ ' |




