Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
# Ways to execute a shell script in Ruby | |
# Example Script - Joseph Pecoraro | |
cmd = "echo 'hi'" # Sample string that can be used | |
# 1. Kernel#` - commonly called backticks - `cmd` | |
# This is like many other languages, including bash, PHP, and Perl | |
# Synchronous (blocking) | |
# Returns the output of the shell command | |
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111 |
class FileQueue | |
def initialize(file_name) | |
@file_name = file_name | |
end | |
def push(obj) | |
safe_open('a') do |file| | |
file.write(obj + "\n") | |
end |
# YUI 3 Cookbook Table of Contents | |
## YUI BASICS | |
### Put YUI on the Page | |
* Load YUI | |
* Load debug builds | |
* Load locally hosted builds | |
* Load a YUI 2 widget |
// I mean, seriously, localStorage is supported even by your mum. How about instead of | |
// casing the feature out, you give users in-memory (stale) storage instead? | |
// If they close your application, they deserve to lose data anyway. | |
// if (!('localStorage' in window)) { | |
if (!Modernizr.localstorage) { | |
window.localStorage = { | |
_data : {}, | |
setItem : function(id, val) { return this._data[id] = String(val); }, | |
getItem : function(id) { return this._data.hasOwnProperty(id) ? this._data[id] : undefined; }, |
#!/usr/bin/php | |
<?php | |
echo "\nRunning php linter...\n"; | |
$params = explode(' ', file_get_contents('php://stdin')); | |
$ref = trim($params[1]); | |
$diff = array(); | |
$return = 0; |
Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns
Compress 1K bytes with Zippy ............. 3,000 ns = 3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns = 20 µs
SSD random read ........................ 150,000 ns = 150 µs
Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs
I'm considering adding an alternative to CanJS's EJS live-binding system. I really like EJS, it's extremely powerful, but ugly to look at. So, I'm trying to create a better mouse-trap.
Currently, the most popular mouse-trap seems to be Handlebars. What do you like about it?
Handlebars uses {{}}
for insertion and {{#}}
and {{/}}
for widgets and control structures.
//------------------------------------------------------------- | |
// | |
// Hypothesis: | |
// | |
// Promises/A is a Monad | |
// | |
// To be a Monad, it must provide at least: | |
// - A unit (aka return or mreturn) operation that creates a corresponding | |
// monadic value from a non-monadic value. | |
// - A bind operation that applies a function to a monadic value |
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.