(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| echo master shard_{0,1,2,3} | xargs -n1 /usr/local/bin/dropdb -p 6432 -h /tmp -U postgres | |
| echo master shard_{0,1,2,3} | xargs -n1 /usr/local/bin/createdb -p 6432 -h /tmp -U postgres | |
| for a in {0..3}; do | |
| echo " | |
| CREATE TABLE users (id serial PRIMARY KEY, username TEXT NOT NULL); | |
| ALTER SEQUENCE users_id_seq INCREMENT BY 4 RESTART WITH $a; | |
| " | /usr/local/bin/psql -p 6432 -h /tmp -U postgres -d shard_$a; | |
| done |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| # Solution 1 | |
| # original solution proposed in the PR | |
| # pro: easy declaration | |
| # cons: instanciation is a little bit hard to write | |
| # possible method conflict with multiple protocols | |
| class MyObjcDelegate: | |
| def connection_didFailWithError_(self, connection, error): | |
| print("Protocol method got called!!", connection, error) | |
| module.exports = function(grunt) { | |
| grunt.initConfig({ | |
| pkg: grunt.file.readJSON( 'package.json' ), | |
| ember_handlebars: { | |
| options: { | |
| processName: function(filePath) { | |
| var shortFilePath = filePath.replace(/assets\/js\/app\/templates\//, '').replace('.hbs', ''); | |
| return shortFilePath; | |
| }, |
| import ctypes | |
| class Point(ctypes.Structure): | |
| _fields_ = ( | |
| ("x", ctypes.c_int), | |
| ("y", ctypes.c_int)) | |
| p1 = Point(23, 4) | |
| print 'Original point is', (p1.x, p1.y) |
| // Facebook SDK | |
| angular.module('facebook', []) | |
| .directive('fb', ['$FB', function($FB) { | |
| return { | |
| restrict: "E", | |
| replace: true, | |
| template: "<div id='fb-root'></div>", | |
| compile: function(tElem, tAttrs) { | |
| return { | |
| post: function(scope, iElem, iAttrs, controller) { |
| if (!Object.__proto__) { | |
| var sandbox = function () { | |
| // create an <iframe> | |
| var iframe = document.createElement("iframe"); | |
| iframe.style.display = "none"; | |
| document.documentElement.appendChild(iframe); | |
| return frames[frames.length - 1]; | |
| } | |
| var iframe = sandbox(); |
| #!/bin/sh | |
| ## | |
| # Install autoconf, automake and libtool smoothly on Mac OS X. | |
| # Newer versions of these libraries are available and may work better on OS X | |
| # | |
| # This script is originally from http://jsdelfino.blogspot.com.au/2012/08/autoconf-and-automake-on-mac-os-x.html | |
| # | |
| export build=~/devtools # or wherever you'd like to build |
This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.
Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:
getTweetsFor("domenic", function (err, results) {
// the rest of your code goes here.In August 2007 a hacker found a way to expose the PHP source code on facebook.com. He retrieved two files and then emailed them to me, and I wrote about the issue:
http://techcrunch.com/2007/08/11/facebook-source-code-leaked/
It became a big deal:
http://www.techmeme.com/070812/p1#a070812p1
The two files are index.php (the homepage) and search.php (the search page)