Skip to content

Instantly share code, notes, and snippets.

View samuraisam's full-sized avatar

Samuel Sutch samuraisam

View GitHub Profile
var MyRoute = Ember.Route.extend({
model: function() {
// this will resolve
return Ember.$.ajax().then(function(data) {
// then this will resolve
return Ember.RSVP.Promise.all([
Ember.$.ajax({url: data.item1url}),
Ember.$.ajax({url: data.item2url})
]).then(function(items) {
// and this will be your model in the controller
@samuraisam
samuraisam / dyn-form-field.js
Created May 11, 2014 18:44
Dynamic component
var elementMap = {
'char': 'dyn-text-field'
};
var DynamicFormField = Ember.Component.extend({
template: Ember.computed('entry.field', function(key, value) {
var kind = this.get('entry.field.kind');
var helperName = elementMap[kind] || 'dyn-text-field';
var tmpl = '{{' + helperName + ' entry=entry}}';
return Ember.Handlebars.compile(tmpl);
my $fn = IO::Spec.catdir($?FILE, 'Proto', 'ql2_13x.proto');
use PB::Model::Generator $fn;
# => No such method 'IO' for invocant of type 'Any'
constant CURDIR = IO::Spec.splitpath($?FILE)[1];
constant FN = IO::Spec.catdir(CURDIR, 'Proto', 'ql2_13x.proto');
module RethinkDB::Proto {
# classes are generated here
use PB::Model::Generator FN;
}
BEGIN {
for RethinkDB::Proto::.kv -> \sym, \obj {
### Keybase proof
I hereby claim:
* I am samuraisam on github.
* I am ssutch (https://keybase.io/ssutch) on keybase.
* I have a public key whose fingerprint is CB73 AA67 8197 4715 8413 0169 52F3 85BF 58A0 3967
To claim this, I am signing this object:
960a14a3b6c5b785ca2c027d9461374a
import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['modal'],
didInsertElement: function() {
var self = this.$();
Ember.run.later(function() {
self.toggleClass('open');
});
import psycopg2
import uuid
import json
conn = psycopg2.connect('dbname=ftest user=ffer password=omgnowai')
cur = conn.cursor()
cur.execute('DROP TABLE IF EXISTS entries')
cur.execute('''
CREATE TABLE entries (
id serial PRIMARY KEY,
require 'webrick'
require 'json'
require_relative 'health_reporter'
module Geronimo
# Geronimo::HealthServer is a HTTP server which is intended to run alongside
# services which do not have an HTTP server.
#
# For example, a service like Sidekiq might extend the class to offer
# health checks related to Sidekiq functions
"""
My dependency injection framework for Python. Using a context manager it allows
you to rewrite globals (such as imports, top-level classes and functions, whatever
you want) in a module and have them replaced at the end of the with block. This is
usually enough. `proxy` is just a dict-wrapping type class which will create a
type with "class variables" for every key you give it.
Usage:
from di import *