Skip to content

Instantly share code, notes, and snippets.

View DC3's full-sized avatar

Dee Cheung DC3

View GitHub Profile
operations =
'*': (a, b) -> a*b
'+': (a, b) -> a+b
evaluate = (arr) ->
calc = (operation, refArr) ->
hasOperation = (index = arr.indexOf(operation)) isnt -1
return refArr unless hasOperation
pos = index - 1
# http://www.1758.com/hlmy/yanse2.htm
$ ->
timeEl = $('.time')
boxEl = $('#box')
interval = null
eachTime = 1 # ms
replaceRE = /[^\d]+/g
getColor = (str) ->
'wkjkjd fsk fsdjk\nbbb sss fasdf'.replace(/(bbb|sss)(\s)?/g, function(match, p1, p2){
var min = 1, max = p1.length - 1,
pos = Math.floor(Math.random() * (max - min + 1)) + min; //randint
return p1.substr(0, pos) + 'a' + p1.substr(pos, p1.length - 1) + p2;
});