Skip to content

Instantly share code, notes, and snippets.

@brow
brow / redis.markdown
Created October 26, 2011 10:13 — forked from bdotdub/redis.markdown
Running redis using upstart on Ubuntu

Running redis using upstart on Ubuntu

I've been trying to understand how to setup systems from the ground up on Ubuntu. I just installed redis onto the box and here's how I did it and some things to look out for.

To install:

@brow
brow / gist:1562617
Created January 4, 2012 22:44
Benchmark concatenating strings with reduce(:+) vs. with join('').
require 'benchmark'
STRING = 'abc'
ITERATIONS = 500000
Benchmark.bm do |bench|
for n in [2,3,4]
n_strings = Array.new(n, STRING)
bench.report("add #{n}") do
require 'benchmark'
STRING = 'abc'
ITERATIONS = 500000
Benchmark.bm do |bench|
for n in [2,3,4]
n_strings = Array.new(n, STRING)
bench.report("add #{n}") do
<html>
<body>
<div id='fb-root'></div>
<script src='http://connect.facebook.net/en_US/all.js#xfbml=1'></script>
<script>
var events = ['edge.create', 'edge.remove', 'xfbml.render'];
for (var i = 0; i < events.length; i++) {
var eventName = events[i];
FB.Event.subscribe(eventName, function(r) { alert(eventName); });
}
## Lorem
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
@brow
brow / gist:5536084
Last active December 17, 2015 02:29

Lorem Ipsum

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

@brow
brow / gist:f52de2d65f9cc710faf8
Created November 21, 2014 06:29
FromJSONObject
# FromJSONObject
FromJSONObject is a protocol adopted by Swift types that can be instantiated
from a dictionary of the sort produced by `NSJSONSerialization` -- and that
produce an informative error when they can't.
```swift
struct Person {
let name: String
let age: Int
@brow
brow / README
Created November 21, 2014 06:30
FromJSONObject
# FromJSONObject
FromJSONObject is a protocol adopted by Swift types that can be instantiated
from a dictionary of the sort produced by `NSJSONSerialization` -- and that
produce an informative error when they can't.
```swift
struct Person {
let name: String
let age: Int
@brow
brow / README.md
Created November 21, 2014 06:30
FromJSONObject

FromJSONObject

FromJSONObject is a protocol adopted by Swift types that can be instantiated from a dictionary of the sort produced by NSJSONSerialization -- and that produce an informative error when they can't.

struct Person {
  let name: String
  let age: Int
@brow
brow / Enqueue.swift
Last active August 29, 2015 14:21
Non-blocking queue in RAC 3
import ReactiveCocoa
public func enqueue<T>(elements: SignalProducer<T, NoError>) -> SignalProducer<T, NoError> {
let (poppers, poppersSink) = Signal<SinkOf<Event<T, NoError>>, NoError>.pipe()
elements
|> zipWith(poppers)
|> start(next: { element, popper in
sendNext(popper, element)
sendCompleted(popper)