I hereby claim:
- I am heycarsten on github.
- I am heycarsten (https://keybase.io/heycarsten) on keybase.
- I have a public key ASBliap-zC_0iOy4RIGc-xRsZfZxHzhZ_d-hFF2JwwUDkwo
To claim this, I am signing this object:
# Python 3.6.1 | |
from urllib.request import urlopen, Request | |
import json | |
url = 'http://lcboapi.com/products?q=gose' | |
req = Request(url) | |
req.add_header( | |
'Authorization', 'Token token="YOUR_API_KEY_HERE"' |
I hereby claim:
To claim this, I am signing this object:
import Ember from 'ember'; | |
import FSM from 'ember-fsm'; | |
const WAIT_TIMES = { | |
'red': 5000, | |
'amber': 3500, | |
'green': 6500 | |
}; | |
export default Ember.Controller.extend(FSM.Stateful, { |
<html> | |
<head> | |
<title>Learnin'</title> | |
<link href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.1/normalize.css" rel="stylesheet"> | |
<style> | |
body { | |
margin: 30px auto; | |
width: 600px; | |
} |
I've had to tackle the client validations problem in almost every Ember app I've ever written, and I've done it in a bunch of different ways. This is the way I ended up liking most. There are a few things that I really wanted to have in a validation framework:
/* | |
Creates a computed property that persists into local storage, all | |
instances share the same value for the same property. | |
App.AuthController = Ember.Controller.extend({ | |
token: Em.computed.stored() | |
}); | |
controller = App.__container__.lookup('controller:auth') | |
contorller.set('token', 'abc123foo456bar') |
/* | |
Creates a computed property that automatically increments itself at the | |
specified interval in milliseconds. Useful when used as a dependent | |
property to properties that need to changed based on time. | |
App.PostController = Ember.ObjectController.extend({ | |
'@timer': Ember.computed.timer(1000), | |
sinceCreated: function() { | |
return new Date().getTime() - this.get('createdAt').getTime(); |
@hvt asks: How’ you create your JSON structure? How did you parse LCBO data to show “result”:{..} KVPs Working off an HTML file currently
I build a hash in Ruby and then serialize it to JSON and send that to the client. Here's an extremely basic example of this in a Rails controller:
class ProductsController < ApplicationController
def index
// These are yoinked from Underscore.js but are added to the function prototype | |
// so that we can ruin the world. | |
(function() { | |
var debounce, throttle; | |
debounce = function(func, wait, immediate) { | |
var timeout; | |
return function() { | |
var context = this, args = arguments; | |
var later = function() { |