This file contains 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
def p(i) | |
(i.to_s.chop.chars<<'%02d'%i).join '/' | |
end |
This file contains 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
String.random=(q=1)-> | |
s='' | |
while s.length<q | |
n=Math.floor 62*Math.random() | |
s+=String.fromCharCode n%26+'Aa0'.charCodeAt n/26 | |
s |
This file contains 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
Function Base64Decode(Const S: String): String; | |
Var | |
i: Integer; | |
W, Buffer, Bits: Word; | |
Begin | |
Result:=''; | |
Bits:=0; Buffer:=0; W:=0; | |
For i:=1 To Length(S) Do | |
Begin | |
Case S[i] Of |
This file contains 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
String::wordWrap=(cols=75, rows=1)-> | |
@match(RegExp ".{1,#{cols}}(\\s|$)|.{#{cols}}|.+$", 'g').slice(0, rows).join '\n' |
This file contains 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
Number::declension=(forms)-> | |
n=/[.,]|1?[1-4]$|$/.exec(@)[0] | |
n=if 1!=n.length then 0 else if '1'==n then 1 else 2 | |
if arguments.length>1 then arguments[n] else if forms then forms[n] else n |
This file contains 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
Function.prototype.new = function(){ | |
var args = arguments | |
var constructor = this | |
function Fake(){ | |
return constructor.apply(this, args) | |
} | |
Fake.prototype = this.prototype | |
return new Fake | |
} |
This file contains 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
positive = /^(?!0\d|\.?$)\d*\.?\d*$/ | |
number = /^[-+]?(?!0\d|\.?$)\d*\.?\d*$/ |
This file contains 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
$.fontAwesome = -> | |
do fontAwesome | |
return | |
fontAwesome = -> | |
$('body').append do withOut.compile -> | |
div id: 'font-awesome-icons', -> | |
button | |
type: 'button' | |
class: 'close' |
This file contains 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
$.pager = pager = (pages, page, click)-> | |
z = $ tPager pages, page | |
x = ul z | |
x.find('a').click -> | |
x.replaceWith ul pager pages, n = Number(@title or $(@).text()), click | |
click? n, pages | |
false | |
z | |
ul = (pager)-> |
This file contains 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
// including . | |
.toFixed(n).replace(/\.0*$|(\.[^0]+)0+$/, '$1') | |
// leaving 1 decimal digit | |
.toFixed(n).replace(/(\..+?)0+$/, '$1') |
OlderNewer