Skip to content

Instantly share code, notes, and snippets.

@boundsj
boundsj / gist:9245097
Created February 27, 2014 05:52
protips
remember to change framework search paths for cedar specs to $(SRCROOT)/Specs/Frameworks to work on CI (i.e. travis)
@boundsj
boundsj / pckit.sh
Last active December 27, 2015 10:49
Add PivotalCoreKit as a submodule
# bash -c "$(curl -fsSL https://gist.github.com/boundsj/7314358/raw/be3e7f29f6d69b067bf9696fa4ebbaab07c62c82/pckit.sh)"
EXTERNALS="Externals"
if [ ! -d $EXTERNALS ]; then
mkdir Externals
fi
git submodule add https://github.com/pivotal/PivotalCoreKit.git Externals/PivotalCoreKit
git submodule init
@boundsj
boundsj / SomeViewController.m
Created November 4, 2013 05:03
JavaScriptCore, Objective-C calln' javascripts
#import "ViewController.h"
@import JavaScriptCore;
@interface ViewController ()
@property (nonatomic, strong) JSContext *context;
@end
@implementation ViewController
@boundsj
boundsj / python_env_mac.md
Last active February 6, 2016 13:07
Setting up a Python environment: Mac

Creating an Agile Python Environment: Mac

This gist assumes you are on a Mac. It also assumes that you already have Python and pip installed and that you are most likely using Python version 2.7.x. If your environment differs you may have to work a little harder to get things sorted but hopefully the gist of the gist (agile Python) will still be useful for you. If you are on a windows machine, this is probably not the gist you are looking for.

We will take the minimum amount of steps nessessary to set up a complete set of tools that are fully controllable from the command line. Use your text editor or IDE of choice for creating the spec and implementation files. Note that some IDEs (i.e. PyCharm) make some of what we cover below a lot easier (i.e. debugging) but it is probably still useful to understand what is going on behind the scenes.

We will create a simple application that pulls down Guido van Rossum's twitter feed and prints out some of his latest perls of wisdo

@boundsj
boundsj / gist:6168910
Created August 6, 2013 21:34
center div
.container {
position: relative;
}
.centered {
position: absolute;
height: 10px;
width: 10px;
top: 50%;
@boundsj
boundsj / counting.py
Created July 31, 2012 20:08
Python 102
###
# how many times have you done something like this?
###
# check if dict has key
# if so then increment value
# if not then add key and init value to 1
def increment(d, v):
if v in d:
@boundsj
boundsj / test.js
Created July 26, 2012 18:58
How to run a jasmine test in a backbone boilerplate app
define([
// Application.
"app",
// Modules
"app/modules/todo"
],
function(app, Todo) {
console.log("test ran");
@boundsj
boundsj / findnear.py
Created July 26, 2012 00:54
Find all the things with a bounding box and no mongo geo.
import math
import pymongo
from pymongo import Connection
# constants to
bbox_earth_radius = 3959.0 # miles
bbox_dist_from_center = 0.1 # miles
def sum_by_distinct_type(dist_type, distinct_key, args):
nearby_requests = db.windygrid.find({"$and": [{"where.latitude": {"$gte": args["ll_y"]}}, \
@boundsj
boundsj / test.js
Created July 20, 2012 19:31
Node global, module, export exercise
var user1 = require('./user.js'),
user2 = require('./user.js'),
assert = require('assert');
// initialize the value in user1
user1.name("test");
// set it to another value in user2
user2.name("ohai");
// user1's value has been changed
assert.equal(user1.name(), "ohai", "oops");
@boundsj
boundsj / cosine_sim_examples.py
Created June 24, 2012 20:27
Cosine Similarity Examples
# -*- coding: utf-8 -*-
from math import sqrt
def vector_length(vector):
"""
Compute length (aka magnitude, Euclidiean norm) of vector.
This gives the ordinary distance from the origin to the point x,
a consequence of the Pythagorean theorem.