Skip to content

Instantly share code, notes, and snippets.

View stevekane's full-sized avatar

Steven stevekane

View GitHub Profile
var rr = new RouteRecognizer
//this is currently used
rr.add([
{path: "whatever", handler: whateverHandler}
]);
//when recognize is run, it will return this
[{handler: whateverHandler, params: {}}]
@stevekane
stevekane / gist:8051456
Created December 20, 2013 07:18
React router example...WIP
var routeManaged = false;
var HashRoutePlugin = {
getCurrentRoute: function() {
return window.location.hash;
},
pushCurrentRoute: function(newRoute) {
window.location.hash = newRoute;
},
setCurrentRoute: function(newRoute) {
@stevekane
stevekane / gist:7764181
Created December 3, 2013 05:11
Curry example for future reference
/**
first arg is a function, second is the number of arguments
to expect before executing
(N.B. The second arg is optional and will default to the arity
of the function if not provided)
*/
function curry (fn, numArgs) {
var numArgs = numArgs || fn.length;
@stevekane
stevekane / gist:7421605
Last active December 28, 2015 01:38
quick n dirty route problem
<div class="row">
<ol class="breadcrumb">
<li>{{#link-to "videos"}}Videos{{/link-to}}</li>
</ol>
</div>
<div class="media">
<div class="media-header">
<h3>{{title}}</h3>
<h4>{{description}}</h4>
<h5>Published on: {{publication_date}}</h5>
@stevekane
stevekane / gist:7376558
Last active December 27, 2015 19:19
Quick sketch of RSVP.Hash wrapper
model: function (params) {
var FetchPromise = Ember.RSVP.Promise(function (resolve, reject) {
Ember.RSVP.hash({
dinosaurs: App.Dinosaur.find(),
ninjas: App.Ninja.find()
})
.then(function (objects) {
resolve(objects);
})
@stevekane
stevekane / gist:6597165
Last active December 23, 2015 06:58
CP of Object proxies that define a "view-specific" attribute
wrapWithProperty = (arrayName, propertyName, value) ->
Ember.computed arrayName + ".[]", ->
@get(arrayName).map( (each) ->
eachHash = {}
eachHash[propertyName] = value
eachHash.content = each
Ember.ObjectProxy.create(eachHash)
)
wrapWithHash = (arrayName, hashName) ->
@stevekane
stevekane / gist:6468526
Created September 6, 2013 19:12
Rough idea for passing along events in a component to component methods
AR.AgentrunPickadateComponent = Ember.Component.extend
events: [
'onOpen',
'onClose',
'onRender',
'onStart',
'onStop',
'onSet'
]
@stevekane
stevekane / gist:6356006
Created August 27, 2013 16:44
ClickElsewhereMixin (an Ember mixin used to detect clicks outside a view) Original Attribution: Alex Speller's gist at https://gist.github.com/alexspeller/6251054
#original attribution https://gist.github.com/alexspeller/6251054
bound = (fnName) -> Ember.computed fnName -> @get(fnName).bind(@)
App.ClickElsewhereMixin = Ember.Mixin.create
#use this method hook to define your desired behavior
onClickElsewhere: Ember.K
#bound version of our instance method
##Hey
here is some normal text
@stevekane
stevekane / gist:5789403
Last active December 18, 2015 13:19
Dashboard setup for Ember cats and dogs
<script type="text/x-handlebars">
<h1>Dashboard</h1>
{{outlet cats}}
{{outlet dogs}}
</script>
<script type="text/x-handlebars" data-template-name="cats">
{{#each cat in controller.content}}
{{cat}}