This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-routines are severely under-utilized in Ruby. | |
There's a truly magical line you can add to the top of a function that yields a bunch of values, | |
`return to_enum(__callee__) unless block_given?` | |
which makes the function return an Enumerator enumerating its values if you don't explicitly pass it a block. | |
As a simple example, consider this, | |
```ruby | |
def numbers | |
return to_enum(__callee__) unless block_given? | |
yield 1 | |
yield 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sysctl kern.maxfiles | |
kern.maxfiles: 12288 | |
$ sysctl kern.maxfilesperproc | |
kern.maxfilesperproc: 10240 | |
$ sudo sysctl -w kern.maxfiles=1048600 | |
kern.maxfiles: 12288 -> 1048600 | |
$ sudo sysctl -w kern.maxfilesperproc=1048576 | |
kern.maxfilesperproc: 10240 -> 1048576 | |
$ ulimit -S -n | |
256 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function crossDomainPost() { | |
// Add the iframe with a unique name | |
var iframe = document.createElement("iframe"); | |
var uniqueString = "CHANGE_THIS_TO_SOME_UNIQUE_STRING"; | |
document.body.appendChild(iframe); | |
iframe.style.display = "none"; | |
iframe.contentWindow.name = uniqueString; | |
// construct a form with hidden inputs, targeting the iframe | |
var form = document.createElement("form"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem "sinatra", :require => "sinatra/base" | |
gem "sinatra-contrib" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <GLUT/glut.h> | |
#include <OpenGL/gl.h> | |
#include <OpenGL/glu.h> | |
#define kWindowWidth 640 | |
#define kWindowHeight 480 | |
unsigned int delay= 10; |