Skip to content

Instantly share code, notes, and snippets.

Understanding Blocks in Ruby

This is a quick, visual explanation of how blocks work in Ruby.

Let's define a function foo that accepts an optional block callback, and calls it if it was passed:

def foo
 puts 'foo 1'
import gevent
import greenlet
import logging
import time
import traceback
_last_switch_time = None
_min_elapsed_time = 0.1
def trace(event, (origin, target)):
diff --git a/phantom-main.js b/phantom-main.js
index 0b6d1a1..a6e2e0a 100644
--- a/phantom-main.js
+++ b/phantom-main.js
@@ -21,6 +21,8 @@ var options = JSON.parse(phantom.args[2] || {});
// Default options.
if (!options.timeout) { options.timeout = 5000; }
+if (!options.uploadDir) { options.uploadDir = fs.workingDirectory; }
+options.uploadDir = fs.absolute(options.uploadDir).replace(/[\/\\]*$/, '') + fs.separator;
@noonat
noonat / http.c
Last active August 29, 2015 14:02
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>
#include "http.h"
int http_response_init(http_response_t * const response)
{