@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).
Here we go with the explanations:
(function(x, f = () => x) {
Understand the Task: Grasp the main objective, goals, requirements, constraints, and expected output. | |
- Minimal Changes: If an existing prompt is provided, improve it only if it's simple. For complex prompts, enhance clarity and add missing elements without altering the original structure. | |
- Reasoning Before Conclusions: Encourage reasoning steps before any conclusions are reached. ATTENTION! If the user provides examples where the reasoning happens afterward, REVERSE the order! NEVER START EXAMPLES WITH CONCLUSIONS! | |
- Reasoning Order: Call out reasoning portions of the prompt and conclusion parts (specific fields by name). For each, determine the ORDER in which this is done, and whether it needs to be reversed. | |
- Conclusion, classifications, or results should ALWAYS appear last. | |
- Examples: Include high-quality examples if helpful, using placeholders [in brackets] for complex elements. | |
- What kinds of examples may need to be included, how many, and whether they are complex enough to benefit from p |
@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).
Here we go with the explanations:
(function(x, f = () => x) {
function escapeUsing(escaper) { | |
return function(literalParts, ...interpolatedParts) { | |
let s = literalParts[0]; | |
for (let [interpolatedPart, literalPart] of zip(interpolatedParts, literalParts.slice(1))) { | |
s += escaper(interpolatedPart) + literalPart; | |
} | |
return s; | |
} | |
} |
#!/usr/bin/python | |
# smartcrop with libvips, based very roughly on | |
# http://stackoverflow.com/a/1517178/894763 | |
import sys | |
from gi.repository import Vips | |
image = Vips.Image.new_from_file(sys.argv[1]) |
A primer/refresher on the category theory concepts that most commonly crop up in conversations about Scala or FP. (Because it's embarassing when I forget this stuff!)
I'll be assuming Scalaz imports in code samples, and some of the code may be pseudo-Scala.
A functor is something that supports map
.
#!/usr/bin/python | |
# smartcrop with libvips, based very roughly on | |
# https://github.com/jwagner/smartcrop.js | |
import sys | |
import gi | |
gi.require_version('Vips', '8.0') | |
from gi.repository import Vips |
/** | |
* = LL parser = | |
* | |
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com> | |
* MIT Style license | |
* | |
* Often one can see manually written LL parsers implemented as | |
* recursive descent. Approach in this diff is a classical parse table | |
* state machine. | |
* |
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine | |
# This is how I upload my new Sol Trader builds (http://soltrader.net) | |
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash | |
S3KEY="my aws key" | |
S3SECRET="my aws secret" # pass these in | |
function putS3 | |
{ | |
path=$1 |
#!/usr/bin/python | |
import sys | |
from gi.repository import Vips | |
N_BINS = 10 | |
BIN_SIZE = 256 / N_BINS | |
im = Vips.Image.new_from_file(sys.argv[1], access = Vips.Access.SEQUENTIAL) |
In all the discussions about ES6 one thing is bugging me. I'm picking one random comment here from this io.js issue but it's something that comes up over and over again:
There's sentiment from one group that Node should have full support for Promises. While at the same time another group wants generator syntax support (e.g.
var f = yield fs.stat(...)
).
People keep putting generators, callbacks, co, thunks, control flow libraries, and promises into one bucket. If you read that list and you think "well, they are all kind of doing the same thing", then this is to you.