- expression-oriented programming one of the great advances of FP
- expressions plug together like legos, making more malleable programming experience in-the-small
Write in an expression-oriented style, scoping variables as locally as possible:
# Shell out to the fast and reliable `wc` utility. | |
def lines(path) | |
# output of wc (returned by backticks) is formatted like this: | |
# " 111 filename.ext" | |
`wc -l #{path}`.strip.split(' ').first.to_i | |
end | |
# **/* gets all files and directories in all subdirectories. | |
files = Dir["/path/to/directory/**/*"] |
# CPU | |
for cpu in 1 2 ; do | |
( while true; do true; done ) & | |
done | |
# IO | |
for cpu in 1 2 ; do | |
( while true; do find / -type f -exec cp {} /dev/null \; ; done ) & | |
done |
// polyfill window.getMatchedCSSRules() in FireFox 6+ | |
if ( typeof window.getMatchedCSSRules !== 'function' ) { | |
var ELEMENT_RE = /[\w-]+/g, | |
ID_RE = /#[\w-]+/g, | |
CLASS_RE = /\.[\w-]+/g, | |
ATTR_RE = /\[[^\]]+\]/g, | |
// :not() pseudo-class does not add to specificity, but its content does as if it was outside it | |
PSEUDO_CLASSES_RE = /\:(?!not)[\w-]+(\(.*\))?/g, | |
PSEUDO_ELEMENTS_RE = /\:\:?(after|before|first-letter|first-line|selection)/g; | |
// convert an array-like object to array |
- certain endpoints are always blocked | |
if nginx_uri == "/_access_token" or nginx_uri == "/_me" then | |
ngx.exit(403) | |
end | |
-- import requirements | |
local cjson = require "cjson" | |
-- setup some app-level vars | |
local app_id = "APP_ID" |
g_LastCtrlKeyDownTime := 0 | |
g_AbortSendEsc := false | |
g_ControlRepeatDetected := false | |
*CapsLock:: | |
if (g_ControlRepeatDetected) | |
{ | |
return | |
} |
/* | |
* robotMaze.js | |
* | |
* The blue key is inside a labyrinth, and extracting | |
* it will not be easy. | |
* | |
* It's a good thing that you're a AI expert, or | |
* we would have to leave empty-handed. | |
*/ |
/***************** | |
* bossFight.js * | |
***************** | |
* | |
* NO FARTHER, DR. EVAL!!!! | |
* YOU WILL NOT GET OUT OF HERE ALIVE!!!! | |
* IT'S TIME YOU SEE MY TRUE FORM!!!! | |
* FACE MY ROBOT WRATH!!!!! | |
*/ |
private static readonly string[] tenHoursOfFun = | |
{ | |
"https://www.youtube.com/watch?v=wbby9coDRCk", | |
"https://www.youtube.com/watch?v=nb2evY0kmpQ", | |
"https://www.youtube.com/watch?v=eh7lp9umG2I", | |
"https://www.youtube.com/watch?v=z9Uz1icjwrM", | |
"https://www.youtube.com/watch?v=Sagg08DrO5U", | |
"https://www.youtube.com/watch?v=5XmjJvJTyx0", | |
"https://www.youtube.com/watch?v=IkdmOVejUlI", | |
"https://www.youtube.com/watch?v=jScuYd3_xdQ", |