Skip to content

Instantly share code, notes, and snippets.

@sdailey
sdailey / keybase.md
Created February 5, 2016 09:14
keybase.md

Keybase proof

I hereby claim:

  • I am sdailey on github.
  • I am sdailey (https://keybase.io/sdailey) on keybase.
  • I have a public key ASAjT_uduzu3YN8jm15i1MtFlZ205-SyctMt815jaBX4lwo

To claim this, I am signing this object:

@sdailey
sdailey / pinterest_spike
Created April 3, 2013 17:59
Here's the pinterest spike
<html>
<head>
<style type="text/css">
img.pinnable {
width: 201px;
height: auto;
z-index: 2;
}
</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
@sdailey
sdailey / eventsSpec.coffee
Created March 16, 2013 01:10
new eventsSpec.coffee with better coverage of expected output. With overlapping tree structure. And different callback results
describe "Events", ->
beforeEach ->
@truth = truth: (term) -> term
@falsehood = falsehood: -> 'other'
@TestObject = @truth
HE.Event.Subscribe "know:truth", @TestObject.truth
@currentChannel = HE.Event.Channels['know:truth'][0]
@callback = @currentChannel.callback
@sdailey
sdailey / gist:5174332
Last active December 15, 2015 00:38
new eventsSpec.coffee with better coverage of expected output. With overlapping tree structure. And different callback results
describe "Events", ->
beforeEach ->
@truth = truth: (term) -> term
@falsehood = falsehood: -> 'other'
@TestObject = @truth
HE.Event.Subscribe "know:truth", @TestObject.truth
@currentChannel = HE.Event.Channels['know:truth'][0]
@callback = @currentChannel.callback
@sdailey
sdailey / gist:5173718
Created March 15, 2013 22:45
event.coffee - with Audit
# Mediator Pattern from: http://addyosmani.com/largescalejavascript/
#
# The HE.Event object manages a list of channels, where each channel
# holds a list of actions.
#
# To subscribe an object to an event:
# HE.Event.Subscribe "event", object.functionToHandleEvent
#
# To publish an event:
# HE.Event.Publish "event"
@sdailey
sdailey / gist:5173716
Last active December 15, 2015 00:29
eventsSpec.coffee - testing Audit - not unit-testy enough - just mapping expected data
describe "Events", ->
beforeEach ->
@truth = truth: (term) -> term
@different = different: -> 'other'
@TestObject = @truth
HE.Event.Subscribe "know:truth", @TestObject.truth
@currentChannel = HE.Event.Channels['know:truth'][0]
@callback = @currentChannel.callback
@sdailey
sdailey / PolygonOverlap.js
Created September 20, 2012 01:22
Polygon overlap detection, javascript
function determinant(vector1, vector2)
{
return vector1.x * vector2.y - vector1.y * vector2.x;
}
function lineSegmentsIntersect(_segment1_Start, _segment1_End, _segment2_Start, _segment2_End)
{ //note the use of 'subtract'
det = determinant(_segment1_End.subtract(_segment1_Start), _segment2_Start.subtract(_segment2_End));
t = determinant(_segment2_Start.subtract(_segment1_Start), _segment2_Start.subtract(_segment2_End)) / det;
@sdailey
sdailey / gist:3741816
Created September 18, 2012 07:38
Solving for angle
//please don't use this in building the next space shuttle :)
//var vertex is an array which has all our points to build our polygon with
testPolygon = new google.maps.Polygon({ paths: vertex, fillColor: color, geodesic: true, fillOpacity: 1, strokeColor: '#00ff00', strokeWeight: 1, strokeOpacity: 0.6 });
count= 0;
while (count<vertex.length){
//lets check the angle between the last two vectors
if (count == vertex.length - 2){
@sdailey
sdailey / gist:3454996
Created August 24, 2012 19:54
Controller Filter for matches with user ID
/**
* Lists models that match user ID.
*/
public function actionIndex()
{
$checkId = yii::app()->user->id;
$dataProvider=new CActiveDataProvider('Crop', array(
'criteria'=>array(
'condition'=>$checkId.'=:userid',
),
@sdailey
sdailey / gist:2822120
Created May 29, 2012 01:57
trouble with custom events
var SessionView = Backbone.View.extend({
el: $(".login_box"),
// ... events, initialize, render ...
temp_button: function(){
console.log('trying');
this.trigger('devicesReady');
}