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
(defmacro when-let ((var test) &body body) | |
"(when-let binding body) | |
binding => binding-form test | |
When test is true, evaluates body with binding-form bound to the value of test" | |
`(let ((,var ,test)) | |
(when ,var | |
,@body))) |
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
(defmacro if-let ((var test) then &optional else) | |
"(if-let binding then else?) | |
binding => binding-form test | |
If test is true, evaluates then with binding-form bound to the value of | |
test, if not, yields else" | |
`(let ((,var ,test)) | |
(if ,var | |
,then | |
,else))) |
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
require 'strscan' | |
lex = [/"[^\\"]*(?:\\.[^\\"]*)*"/, # string | |
/'[^\\']*(?:\\.[^\\']*)*'/, # char | |
/\/\*.*?\*\//m, # multi-line | |
/\/\/(?:.*?\\(?:\r?\n|\r))*.*/, # single-line | |
/.|\s+/] # rest | |
ARGV.each do |source| | |
stream = StringScanner.new File.read source |
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 clever way to implement string multiplication in JavaScript */ | |
String.prototype.times = function(n) { | |
return Array.prototype.join.call({length:n+1}, this); | |
}; | |
"js".times(5) // => "jsjsjsjsjs" |
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
#!/bin/sh | |
until [ -z $1 ]; do | |
unix2dos $1 2>/dev/null | |
iconv -f UTF-8 -t GBK $1 -o /tmp/unix2doc.tmp 2>/dev/null | |
if [ $? -eq 0 ]; then | |
mv /tmp/unix2doc.tmp $1 | |
echo "linux2win: converting file $1 to WIN format ..." | |
else |
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
#include <stdio.h> | |
long x[]={1, 3,6,8,0,0,0,0, 32,32, | |
4,32, 1022,32,1020,36 ,32,1022, 34,508,32 , | |
32,509,34 , 508,32,36, 32,0,32,36,1022,508,80, | |
1023, 32,260 ,136, | |
32, 32 , 508 , 260,32 , 32, | |
0404, 514, 32,32 ,0,0,0 ,0x0, | |
994 , 0466, 0772, 47,548,950, 168, 296, 559, | |
694,69 ,174, 0x228, 0x3B6 , 01646,0141,01744, | |
01266 ,0124 ,2033 |
NewerOlder