Skip to content

Instantly share code, notes, and snippets.

View rbonvall's full-sized avatar

Roberto Bonvallet rbonvall

View GitHub Profile
@hanachin
hanachin / evens-only-co.scm
Created July 3, 2011 16:41
The Little Schemer evens-only*&co
(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
@jrburke
jrburke / gist:1262861
Created October 4, 2011 21:26
Universal (AMD/Node/plain browser) module
/**
* 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) {
@cmaureir
cmaureir / zmq_empty_issue
Created February 23, 2012 23:06
ZeroMQ empty message issue
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)
@datagrok
datagrok / gist:2199506
Last active April 8, 2023 17:36
Virtualenv's `bin/activate` is Doing It Wrong
@mattrobenolt
mattrobenolt / jinja.py
Created May 23, 2012 01:48
A CLI interface to Jinja2
#!/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
@drewlesueur
drewlesueur / y_combinator.md
Created June 27, 2012 06:21
How to generate the Y-Combinator in coffeescript

How to Generate the Y-Combinator in CoffeeScript

Problem

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

@n1k0
n1k0 / Howto.md
Created October 1, 2012 17:59
CasperJS test cli hooks example

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
@mbostock
mbostock / .block
Last active November 7, 2023 07:54
Collapsible Tree
license: gpl-3.0
redirect: https://observablehq.com/@d3/d3-collapsible-tree
@desandro
desandro / require-js-discussion.md
Created January 31, 2013 20:26
Can you help me understand the benefit of require.js?

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.


@robmiller
robmiller / .gitconfig
Created July 17, 2013 07:52
Some useful Git aliases that I use every day
#
# 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)"