Skip to content

Instantly share code, notes, and snippets.

Ian Terrell ianterrell

Block or report user

Report or block ianterrell

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ArcheMedX SSO Example.rb
require 'securerandom'
require 'base64'
require 'uri'
# This is probably provided by a library in your language.
def encrypt(data)
salt = ""
8.times { salt << rand(255).chr }
cipher = OpenSSL::Cipher::Cipher.new("aes-256-cbc")
cipher.encrypt
@ianterrell
ianterrell / rgb_led.particle.c
Last active Jan 15, 2017
RGB LED Particle Photon Basic Firmware
View rgb_led.particle.c
// From http://diotlabs.daraghbyrne.me/2-leds-continued/using-rgb-leds/
int redPin = D0; // RED pin of the LED to PWM pin **A4**
int greenPin = D2; // GREEN pin of the LED to PWM pin **D0**
int bluePin = D3; // BLUE pin of the LED to PWM pin **D1**
int redValue = 255; // Full brightness for an Cathode RGB LED is 0, and off 255
int greenValue = 255; // Full brightness for an Cathode RGB LED is 0, and off 255
int blueValue = 255; // Full brightness for an Cathode RGB LED is 0, and off 255</td>
void setup()
@ianterrell
ianterrell / GenerateEquatable.swift
Last active Oct 13, 2016 — forked from Ben-G/GenerateEquatable.swift
Generate Equatable in terms of member fields
View GenerateEquatable.swift
//: Playground - noun: a place where people can play
import UIKit
func generateEquatable(_ t: Any) -> String {
var output = ""
let mirrorPlace = Mirror(reflecting: t)
let type = mirrorPlace.subjectType
output += ("extension \(type): Equatable {\n")
View injectable.swift
// This handles most storyboard style injection needs
extension UIViewController {
func injectable<T>() -> T? {
var controller: UIViewController? = self
if let nav = self as? UINavigationController {
controller = nav.viewControllers.first
}
return controller as? T
}
View execute_loop changes.js
function execute_loop() {
var vmfunc, pathtab, path;
var pathstart, pathend;
if (resumefuncop) {
//qlog("### at resume time, storing value " + resumevalue + " at funcop " + resumefuncop.key);
store_operand_by_funcop(resumefuncop, resumevalue);
resumefuncop = null;
resumevalue = 0;
}
@ianterrell
ianterrell / BDD.swift
Last active Aug 29, 2015
Rspec style matchers for Swift
View BDD.swift
import XCTest
protocol Matchable : Equatable, Comparable { }
class Matcher<T : Matchable> {
let subjectWrapper: T[]
var subject: T {
get {
return subjectWrapper[0]
View de-casteljau.c
#define p1prime(p1,p2,p3,p4) (u0*u0*u0*p1 + (t0*u0*u0 + u0*t0*u0 + u0*u0*t0)*p2 + (t0*t0*u0 + u0*t0*t0 + t0*u0*t0)*p3 + t0*t0*t0*p4)
#define p2prime(p1,p2,p3,p4) (u0*u0*u1*p1 + (t0*u0*u1 + u0*t0*u1 + u0*u0*t1)*p2 + (t0*t0*u1 + u0*t0*t1 + t0*u0*t1)*p3 + t0*t0*t1*p4)
#define p3prime(p1,p2,p3,p4) (u0*u1*u1*p1 + (t0*u1*u1 + u0*t1*u1 + u0*u1*t1)*p2 + (t0*t1*u1 + u0*t1*t1 + t0*u1*t1)*p3 + t0*t1*t1*p4)
#define p4prime(p1,p2,p3,p4) (u1*u1*u1*p1 + (t1*u1*u1 + u1*t1*u1 + u1*u1*t1)*p2 + (t1*t1*u1 + u1*t1*t1 + t1*u1*t1)*p3 + t1*t1*t1*p4)
View gist:2471387
class NSString < Mobi::Cocoa::Object
end
class UIAlertView < Mobi::Cocoa::Object
def self.alert(title, message, options={})
alert = UIAlertView._alloc \
._initWithTitle _S(title),
:message, _S(message),
:delegate, nil,
:cancelButtonTitle, options[:cancel_title] ? _S(options[:cancel_title]) || nil,
@ianterrell
ianterrell / gist:1102751
Created Jul 24, 2011 — forked from deathbob/gist:1102683
Meta module madness
View gist:1102751
module Foo
def bar
@bar ||= self.snakes
end
end
class Baz
def self.snakes
[:cobra]
View foo.rb
module Foo
def self.included(base)
class << base
attr_accessor :bar
end
end
def set
self.class.bar = "hello there"
end
You can’t perform that action at this time.