Skip to content

Instantly share code, notes, and snippets.

View benjiwheeler's full-sized avatar

Ben Wheeler benjiwheeler

View GitHub Profile
@benjiwheeler
benjiwheeler / index.html
Created May 26, 2015 22:35
Ionic canonical 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 April 21, 2015 15:43
Heroku deployment file
{
"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 / gradient.js
Last active September 30, 2022 13:02
Simple way to cycle through gradient background colors
css:
#gradient {
width: 100%;
height:100%;
background-color: rgb(186,115,255);
}
html:
<body>
<div id="gradient">
@benjiwheeler
benjiwheeler / Gemfile
Last active July 22, 2016 03:24
Gemfile canonical
#######################################
# 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 17:49
.gitignore canonical
# 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 January 4, 2015 03:47
Canonical 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 December 9, 2014 22:14
recursive quality scoring class that allows for arbitrary scoring methods and cycles of dependency
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 January 19, 2018 14:06
Example of Test::Unit code from Underground rails application, using FactoryGirl to generate test objects
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)
@benjiwheeler
benjiwheeler / parsecloudcode.js
Created July 12, 2014 19:51
Parse cloud code example
drizzle_parse_cloud / cloud / main.js
// ************************* libraries ***********************************
var _ = require('underscore');
var moment = require('moment');
//var moment = require('moment-timezone');
var MAX_ALERT_LENGTH = 110;
var TARGET_TIME_OF_DAY_SEC = 7 * 3600; // 7 am
var TIME_OF_DAY_ABS_DIFF_LIMIT = 40 * 60; // within 40 mins
@benjiwheeler
benjiwheeler / zip3 to timezone json
Created July 10, 2014 04:05
zip3 to timezone json
{
"005": {"std_tz": "EST", "std_utc_diff": -5, "dst_tz": "EDT", "dst_utc_diff": -4, "state": "NY", "eg_city": "Holtsville"}
,"010": {"std_tz": "EST", "std_utc_diff": -5, "dst_tz": "EDT", "dst_utc_diff": -4, "state": "MA", "eg_city": "Agawam"}
,"011": {"std_tz": "EST", "std_utc_diff": -5, "dst_tz": "EDT", "dst_utc_diff": -4, "state": "MA", "eg_city": "Indian_Orchard"}
,"012": {"std_tz": "EST", "std_utc_diff": -5, "dst_tz": "EDT", "dst_utc_diff": -4, "state": "MA", "eg_city": "Adams"}
,"013": {"std_tz": "EST", "std_utc_diff": -5, "dst_tz": "EDT", "dst_utc_diff": -4, "state": "MA", "eg_city": "Ashfield"}
,"014": {"std_tz": "EST", "std_utc_diff": -5, "dst_tz": "EDT", "dst_utc_diff": -4, "state": "MA", "eg_city": "Ashburnham"}
,"015": {"std_tz": "EST", "std_utc_diff": -5, "dst_tz": "EDT", "dst_utc_diff": -4, "state": "MA", "eg_city": "Auburn"}
,"016": {"std_tz": "EST", "std_utc_diff": -5, "dst_tz": "EDT", "dst_utc_diff": -4, "state": "MA", "eg_city": "Cherry_Valley"}
,"017": {"std_tz": "EST", "std_utc_diff": -5, "