Skip to content

Instantly share code, notes, and snippets.

@TylerBrock
TylerBrock / magic.cpp
Last active August 29, 2015 14:05 — forked from acmorrow/magic
#ifndef LIBFOO_H_INCLUDED
#define LIBFOO_H_INCLUDED
#pragma once
#include "libfoo_export.h"
#if defined(__cplusplus)
#define LIBFOO_NOEXCEPT noexcept
extern "C" {
@TylerBrock
TylerBrock / hack.sh
Created April 2, 2012 19:22 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@TylerBrock
TylerBrock / mongodb_sharding.txt
Created May 13, 2012 23:09 — forked from squarism/mongodb_sharding.txt
MongoDB sharded cluster install
OS Setup
- Install VMs (base OS = Ubuntu 11.04)
- 6GB disk is not enough. Probably 20-40GB would be good. Mongo has a lot of compression and cleanup features coming.
- Create user to run MongoDB as
- Get DNS or Hosts file set up so all nodes in the cluster can talk to each other
- Generate ssh-keygen -t rsa
- Copy ssh public keys from each node to node01. Then cat all keys to authorized_keys. Then copy that file to each node. Each node will have ssh key trust now. You will also want to ssh from node01 to 02,03,04; from node02 to 01,03,04 etc to test it out.
- Create an initial architecture:
node01: master (replica set 1)
node02: slave (replica set 1)
@TylerBrock
TylerBrock / aggregate.js
Created June 25, 2012 17:53 — forked from cwestin/aggregate.js
Mongo shell script and sample documents used for my aggregation talk at MongoSF
/* sample aggregate command queries */
// make sure we're using the right db; this is the same as "use mydb;" in shell
db = db.getSisterDB("aggdb");
// just passing through fields
var p1 = db.runCommand(
{ aggregate : "article", pipeline : [
{ $project : {
tags : 1,
pageViews : 1
@TylerBrock
TylerBrock / aggregation.js
Created June 25, 2012 18:18 — forked from cwestin/aggregation.js
Mongo shell script and sample documents used for my aggregation talks 12/2011
// make sure we're using the right db; this is the same as "use aggdb;" in shell
db = db.getSiblingDB("aggdb");
// simple projection
var p1 = db.runCommand(
{ aggregate : "article", pipeline : [
{ $project : {
tags : 1,
pageViews : 1
}}
db.getSiblingDB("admin");
var databases = null;
databases = db.runCommand("listDatabases");
if(databases){
for(var i=0;i<databases.databases.length;i++){
//TODO skip if it's the admin database
@TylerBrock
TylerBrock / latency.txt
Created July 2, 2012 19:54 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
db.getSiblingDB("admin");
var databases = null;
databases = db.runCommand("listDatabases");
if(databases){
for(var i=0;i<databases.databases.length;i++){
//TODO skip if it's the admin database
@TylerBrock
TylerBrock / mac-app.rb
Created September 12, 2012 18:14 — forked from havenwood/mac-app.rb
Create an OS X .app Executable With Your Choice Of Language For Script
require 'builder'
module MacApp
class << self
def new
ask_name
ask_file_extension
ask_language
create_directories
@TylerBrock
TylerBrock / Gemfile
Created September 19, 2012 04:12
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
gem "tzinfo"
# Let's use thin