This article is now published on my website: Prefer Subshells for Context.
(define (atom? x) | |
(and (not (pair? x)) | |
(not (null? x)))) | |
(define evens-only*&co | |
(lambda (l col) | |
(cond ((null? l) (col '() 1 0)) | |
((atom? (car l)) | |
(cond ((even? (car l)) | |
(evens-only*&co |
/** | |
* First, better, "set exports/return" option | |
*/ | |
(function (define) { | |
//The 'id' is optional, but recommended if this is | |
//a popular web library that is used mostly in | |
//non-AMD/Node environments. However, if want | |
//to make an anonymous module, remove the 'id' | |
//below, and remove the id use in the define shim. | |
define('id', function (require) { |
I'm trying to develop the following messaging structure | |
A -> B -> C | |
A: | |
-send a message to B (send) | |
-waits for a B answer (recv) | |
B: | |
-receive the A message (recv) |
#!/usr/bin/env python | |
""" | |
jinja2 | |
====== | |
A CLI interface to jinja2. | |
$ jinja helloworld.tmpl data.json --format=json | |
$ cat data.json | jinja helloworld.tmpl | |
$ curl -s http://httpbin.org/ip | jinja helloip.tmpl | |
$ curl -s http://httpbin.org/ip | jinja helloip.tmpl > helloip.html |
For fun, let's say you are programming in a language that doesn't allow variable assignments and you still want to make a recursive function. Although you can't assign variables, you can use functions (and enclosed function arguments). Can you make a function recursive without calling it by name?
Lets try implementing the factorial function. First with a function calling itself by name, then with a funtion that never calls itself by name
Here is the implementation of factorial that calls itself by name. It's a simple recursive function
Put test1.js
and test2.js
into a tests/
directory, then run the suite:
$ casperjs test tests/ --pre=pre.js --includes=inc.js --post=post.js
Test file: /Users/nperriault/tmp/pre-inc/pre.js
Hey, I'm executed before the suite.
Test file: /Users/nperriault/tmp/pre-inc/tests/test1.js
# this is test 1
Hi, I've been included.
PASS Subject is strictly true
license: gpl-3.0 | |
redirect: https://observablehq.com/@d3/d3-collapsible-tree |
I'm having trouble understanding the benefit of require.js. Can you help me out? I imagine other developers have a similar interest.
From Require.js - Why AMD:
The AMD format comes from wanting a module format that was better than today's "write a bunch of script tags with implicit dependencies that you have to manually order"
I don't quite understand why this methodology is so bad. The difficult part is that you have to manually order dependencies. But the benefit is that you don't have an additional layer of abstraction.
# | |
# Working with branches | |
# | |
# Get the current branch name (not so useful in itself, but used in | |
# other aliases) | |
branch-name = "!git rev-parse --abbrev-ref HEAD" | |
# Push the current branch to the remote "origin", and set it to track | |
# the upstream branch | |
publish = "!git push -u origin $(git branch-name)" |