Skip to content

Instantly share code, notes, and snippets.

View mobyjames's full-sized avatar
🤔

James Jacoby mobyjames

🤔
View GitHub Profile
@mobyjames
mobyjames / Fixtures.rb
Created November 2, 2012 16:38
Manage development (or other) data using fixtures
namespace :db do
namespace :fixtures do
task :dump, [:table] => [:environment] do |t, args|
sql = "SELECT * FROM %s"
skip_tables = ["schema_info", "schema_migrations", "delayed_jobs", "sessions", "versions"]
ActiveRecord::Base.establish_connection(Rails.env)
tables = nil
if args[:table].nil?
@mobyjames
mobyjames / MovingAverage.swift
Created January 31, 2015 04:08
Moving Average
class MovingAverage {
var samples: Array<Double>
var sampleCount = 0
var period = 5
init(period: Int = 5) {
self.period = period
samples = Array<Double>()
}
@mobyjames
mobyjames / Delay.swift
Created January 31, 2015 04:33
Delay Block
func delaySeconds(seconds: Double, closure: ()->()) {
dispatch_after(
dispatch_time(
DISPATCH_TIME_NOW,
Int64(seconds * Double(NSEC_PER_SEC))
),
dispatch_get_main_queue(),
closure
)
}
@mobyjames
mobyjames / salesforce.js
Created July 8, 2015 18:15
Squarespace Forms Integration for Salesforce
Y.namespace('Template').Salesforce = Class.create({
/*
baseUrl
oid
sqsFormSubmit
*/
initialize: function (config) {
this.config = config;
},
@mobyjames
mobyjames / bb8-hub.js
Last active March 13, 2017 03:40
BB-8 Internet of Things Hub
var sphero = require('sphero-pwn'),
exec = require('exec'),
macros = require('sphero-pwn-macros'),
keypress = require("keypress");
var orb = null,
id = 'ble://##:##:##:##:##:##';
var awsIot = require('aws-iot-device-sdk');
@mobyjames
mobyjames / doorbell.ino
Created March 25, 2016 19:15
Doorbell Messenger
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <Temboo.h>
#define TEMBOO_ACCOUNT "YOUR_TEMBOO_ACCOUNT_NAME"
#define TEMBOO_APP_KEY_NAME "YOUR_TEMBOO_APP_KEY_NAME"
#define TEMBOO_APP_KEY "YOUR_TEMBOO_APP_KEY"
#define TEMBOO_CHOREO_NAME "YOUR_CHOREO_PROFILE_NAME"
#define WIFI_SSID "YOUR_WIFI_SSID"
{
"ItemType": "Messages",
"Item": null,
"Items": [
{
"AccountID": "001M000000ta17yIAA",
"PetID": "",
"CaseID": "",
"Hide": false,
"IsProcessed": true,
@mobyjames
mobyjames / Moby Vagrant Instructions.md
Last active June 2, 2016 16:21
How to Vagrant at Moby

#Moby Vagrant Instructions

###One-time Workstation Setup

  • Open terminal and run the follwing commands
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew cask install virtualbox
$ brew cask install vagrant
@mobyjames
mobyjames / cross-domain-ga-eventbrite.md
Created June 7, 2016 17:11
A summary of the methods used to enable cross-domain support between a primary domain an an Eventbrite event

#Cross-domain Google Analytics + Eventbrite

Goal

Allow continuous tracking across two primary domains (primarydomain.com and eventbrite.com) in order to track the success of marketing initiatives.

Steps to Setup GA for Events

  1. Ensure that no live events are using "classic tracking"
  2. Go to manage page and select "manage" for the desired event
@mobyjames
mobyjames / clock.swift
Last active September 20, 2016 20:06
Broken Clock
import UIKit
import QuartzCore
import XCPlayground
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
class ClockView: UIView {
let backgroundLayer = CAShapeLayer()
let faceLayer = CAShapeLayer()