Task: get the millisecond component as an actual number (not a string) from a native "datetime" object of some popular dynamic languages.
This is incomprehensible
DateTime.now.to_time.to_f % 1 * 1000
(defn fib [n] | |
(->> | |
(-> | |
(fn [[a b]] [b (+' a b)]) | |
(iterate [1 1])) | |
(map first) | |
(take n))) | |
(fib 5) ;; (1 1 2 3 5) |
<?php | |
if (preg_match('/\.(?:png|jpg|jpeg|gif|js|css)$/', $_SERVER["REQUEST_URI"])) { | |
return false; | |
} else { | |
include __DIR__ . '/index.php'; | |
} |
$phi: 1.61803398874989; //"Golden Ratio" | |
$base-size: 1rem; | |
@function size($n) { | |
$size: $base-size; | |
@if $n > 0 { | |
@for $i from 1 through $n { | |
$size: $size * $phi; | |
} |
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain user |
Extract one specific line with AWK
awk 'NR==40550{print;exit}' <file>
Extract line 40550 to 40601:
sed '40602q;40550,40601!d' <file>
awk 'NR==40550,NR==40601' <file>
Extract line 60451 and 68451:
sed -n '68452q;60451p;68451p' <file>
awk 'FNR==60451 || FNR==68451 {print}; FNR==68452 {exit}'
Generate 1GB files quickly (instantly):
dd if=/dev/zero of=test.img bs=1024 count=0 seek=$[1024*1024]
Generate 1GB files with realistic copy delay:
dd if=/dev/zero of=test.img bs=1024 coun=$[1024*1024] seek=0
ffmpeg -i input.wav -ab 192k -acodec libfaac output.mp4 |