Skip to content

Instantly share code, notes, and snippets.

@raytiley
raytiley / auth.js
Last active August 29, 2015 13:56
A controller using SimpleLogin from Firebase. Returns promises from login / logout to make working with Ember Routing simple.
var dbRef = new Firebase("https://YOUR-FIREBASE.firebaseio.com/");
export default Ember.Controller.extend({
/**
@property currentUser
@type {User}
@default null
*/
currentUser: null,
@vaughnd
vaughnd / gist:9246309
Created February 27, 2014 08:16
Atomic find-or-create in datomic
;; Schema
{:db/doc "Find or create tag atomically."
:db/ident :find-or-create-tag
:db/fn #db/fn {:lang "clojure"
:params [mydb n key value]
:code (when (empty? (d/q '[:find ?e :in $ ?ns ?key ?value :where
[?e :meta/tag-namespace ?n]
[?e :meta/tag-key ?key]
[?e :meta/tag-value ?value]]
@tom-galvin
tom-galvin / prim.clj
Created August 10, 2014 12:45
Implement's Prim's algorithm in Clojure
; Input via stdin
; Formatted as described in reddit.com/r/dailyprogrammer/comments/20cydp/14042014_challenge_152_hard_minimum_spanning_tree/
(defn with-index [coll]
(map-indexed vector coll))
(defn get-adjacency []
(with-index (map with-index
(repeatedly (read-string (read-line))
#(map read-string (clojure.string/split (read-line) #", *"))))))
@pixelhandler
pixelhandler / slides.js
Created January 14, 2015 17:59
Ember CLI http-mock backed by RethinkDB
/*
Add `nouns` as http mocks and use in a local db, available via API in develoment
* Install the adapter `npm install rethinkdb_adapter --save-dev`
* Install RethinkDB, see https://github.com/pixelhandler/ember-slide-deck/blob/master/bin/install_rethinkdb.sh
* Start db `rethinkdb`
* Setup Db and Table, see https://github.com/pixelhandler/ember-slide-deck/blob/master/bin/setup_db.js
* Generate a mock `ember g http-mock nouns` and edit your mock to use the db, see code below for 'slides'
* Set your application adapter to use `namespace: 'api'`
* In our routes use Ember Data in your model hook

2011.03.10

Recursive Interfaces for Reactive Objects by Travers

Talks briefly about Kay's Vivarium Project... TODO: find out more

Frames

@mrjjwright
mrjjwright / nosqlite_blueprint.txt
Created April 29, 2010 20:35
The blueprint for a radically new version of my project NoSQLite
Topic
- NoSQLite
- Consider 3 useful things:
- SQLite - SQLite is itself a great datastore because it is a
fast and powerful SQL database in one file and is widely
deployed and supported.
- JSON - JSON is a simple and cruft free way to describe and
transport objects. That is why programmers love it. There is
good support for it in virtually every language.
- HTTP - HTTP allows things to connect and talk to each other.
@tater9104
tater9104 / Knockout_Tablesorter.js
Created March 30, 2012 21:52
Utilizing Knockout.JS & Tablesorter together.
// Using Knockout and Tablesorter is a little tricky due to the fact that
// knockout tends to have a slight delay in load (if you are making an ajax call)
// and that table sorter likes to cache its value. To make them work together,
// on need to pay attention to execution order...
//
// Credit: Steve Sanderson http://bit.ly/H1B2Jm
// When binding your table, be sure to use the postAction event on the data-bind
// attribute to call the tablesorter() update method on your view:
//
@danmartens
danmartens / ember.array_extensions.js.coffee
Created June 8, 2012 19:21
Ember.js Array Extensions
# Sorts an array based on a property of each object within the array
#
# Examples:
#
# [Em.Object.create(a: 1), Em.Object.create(a: 5), Em.Object.create(a: 3)].sortProperty('a')
# > [{a: 1}, {a: 3}, {a: 5}]
#
# As a computed property:
#
# AC = Em.ArrayController.extend
@newbyca
newbyca / password.coffee
Created June 17, 2012 03:20
a password class i'm using in my nodejs project. i decided this abstraction was appropriate given a desire to create password hashs asyncly.
bcrypt = require 'bcrypt'
class password
text = null
salt = null
hash = null
@saltAndHash = (text, done) ->
bcrypt.genSalt (err, salt) ->
@terjesb
terjesb / upsert-auto.clj
Created August 3, 2012 11:19
Upserting in Datomic
(use '[datomic.api :only (q db) :as d])
(def initial-data
[{:sku "1" :price 0.95M :qty 1}
{:sku "2" :price 1.99M :qty 0}
{:sku "3" :price 1.99M :qty 0}
{:sku "4" :price 5.99M :qty 3}
{:sku "5" :price 9.99M :qty 2}
{:sku "6" :price 2.99M :qty 3}
{:sku "7" :price 2.99M :qty 2}])