Skip to content

Instantly share code, notes, and snippets.

Avatar

Benjamin Wheeler benjiwheeler

View GitHub Profile
View NSLayoutConstraint+Init.swift
//
// NSLayoutConstraint+Init.swift
// Created by Benjamin Wheeler starting 6/2013
//
//
import UIKit
// improves the clarity and flexibility of NSLayoutConstraint
extension NSLayoutConstraint {
@benjiwheeler
benjiwheeler / rect.html
Created Jun 10, 2015
Processing simple rectangle in javascript
View rect.html
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/processing.js/1.4.9/processing.js"></script>
</head>
<body>
<div>
<canvas id="canvas" width="600" height="600" />
</div>
The content of the body element is displayed in your browser.
@benjiwheeler
benjiwheeler / Code.gs
Created May 27, 2015
Autosort button script for Google Sheets
View Code.gs
function resort(tableRange, columnToSortBy){
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange(tableRange);
range.sort( { column : columnToSortBy, ascending: false } );
}
// just a wrapper; timestamp is just anti-cacheing trick
function myGetRangeByName(n, timestamp) {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
@benjiwheeler
benjiwheeler / index.html
Created May 26, 2015
Ionic canonical index.html
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, width=device-width">
<title></title>
<!-- compiled css output -->
<link href="css/ionic.app.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
@benjiwheeler
benjiwheeler / app.json
Created Apr 21, 2015
Heroku deployment file
View app.json
{
"name": "Stream example ruby app",
"description": "A simple Pinterest clone built with Rails 4 and stream_rails",
"website": "https://getstream.io",
"keywords": [
"getstream.io",
"HTML5",
"PHP"
],
"repository": "https://github.com/GetStream/stream-example-ruby",
@benjiwheeler
benjiwheeler / Gemfile
Last active Jul 22, 2016
Gemfile canonical
View Gemfile
#######################################
# CANONICAL GEMS
# lives at https://gist.githubusercontent.com/brw12/d508024dcd7e230e4a88/raw/2e65efe2a145dda7ee51d1741299f848e5bf752e/Gemfile
#######################################
#######################################
# CORE SETUP
#######################
# core setup
source 'https://rubygems.org'
@benjiwheeler
benjiwheeler / .gitignore
Last active May 10, 2017
.gitignore canonical
View .gitignore
# originally copied from https://help.github.com/articles/ignoring-files
# i manually keep this in sync with https://gist.github.com/benjiwheeler/d100b0c4ed7fbce3dfce
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
@benjiwheeler
benjiwheeler / circle.yml
Created Jan 4, 2015
Canonical circle.yml
View circle.yml
general:
build_dir: .
machine:
environment:
RAILS_ENV: "test"
RACK_ENV: "test"
# note: DON'T need to have heroku: section anywhere because we use --app heroku commands.
@benjiwheeler
benjiwheeler / quality.rb
Created Dec 9, 2014
recursive quality scoring class that allows for arbitrary scoring methods and cycles of dependency
View quality.rb
class Quality < ActiveRecord::Base
belongs_to :measureable, :polymorphic => true, :inverse_of => :qualities
# translates a raw value to a log scale, using expected mean and halflife.
# eg, suppose we're scoring the relative reliability of something based on its age.
# if 10 days is halflife, and expected mean is 2 days, the raw values and log values will be:
# raw value | log value
# --------------------------
# 0 days | -.17
# 1 day | -.09
@benjiwheeler
benjiwheeler / groups_controller_test.rb
Last active Jan 19, 2018
Example of Test::Unit code from Underground rails application, using FactoryGirl to generate test objects
View groups_controller_test.rb
require 'test_helper'
class GroupsControllerTest < ActionController::TestCase
test "ok to create duplicate group through api" do
user = create(:user)
@request.env["HTTP_AUTHORIZATION"] = user.basic_auth_header("abc1234")
post :apicreate, format: :json, nickname: "hannabarbera"
assert_response :created
assert_not_nil assigns(:group)