Skip to content

Instantly share code, notes, and snippets.

View dallonf's full-sized avatar

Dallon Feldner dallonf

View GitHub Profile
class SessionsController < ApplicationController
layout 'basic'
def new
end
def create
puts params[:email]
puts params[:password]
@dallonf
dallonf / app.ts.js
Last active December 13, 2015 20:28
Using the Quintus Engine with TypeScript. This is just a proof-of-concept, it's WAY too early to actually use.
/// <reference path="quintus.d.ts" />
var Q = Quintus()
.include("Sprites, Scenes, Input");
// No need to call Q.Sprite.extend
class Player extends Q.Sprite {
init(p) {
super.init(p, {
asset: "somegraphic.png",
@dallonf
dallonf / await-script-compiled.js
Created November 13, 2012 19:39
AwaitScript compiler concept
// AwaitScript sample compiled to JavaScript
var async = require('async');
function recurse(path, fn) {
var files = [];
fs.readdir(path, function(err, dir) {
if (err) return fn(err);
async.forEach(dir, function(f, fn) {
fs.stat(f, function(err, stat) {
if (err) return fn(err);
@dallonf
dallonf / rewrite.js
Created November 5, 2012 15:35
Rewrite Resource
var Resource = require('deployd/lib/resource')
, util = require('util');
function Rewrite(name, options) {
Resource.apply(this, arguments);
this.rewriteUrl = this.config.rewriteUrl || '/index.html';
}
util.inherits(Rewrite, Resource);
module.exports = Rewrite;
@dallonf
dallonf / gist:3900008
Created October 16, 2012 15:32
Relationships in Deployd
// On GET /users
// Get all the todos that this user owns
if (query.includeTodos) { // Always make something like this a custom query; otherwise it's easy to bog down your server with unnecessary db calls
dpd.todos.get({userId: this.id}, function(res, err) { // Assuming that the userId property of a todo is set when you create it
this.todos = res;
});
}
@dallonf
dallonf / route-event.js
Created October 15, 2012 15:21
Route Event resource
var Resource = require('deployd/lib/resource')
, Script = require('deployd/lib/script')
, util = require('util');
function RouteEvent() {
Resource.apply(this, arguments);
}
util.inherits(RouteEvent, Resource);
RouteEvent.label = "Route Event";
@dallonf
dallonf / gist:3827586
Created October 3, 2012 15:30
AwaitScript concept
require 'fs';
require 'path';
// Check recursively if any files from this directory have been modified since a certain date
async function isRecentlyModified(dir, since) {
var files;
try {
files = await fs.readdir(dir);
} catch (ex) {
console.error("Warning: " + dir + " does not exist")
@dallonf
dallonf / get-departments.js
Created September 27, 2012 16:13
Managing groups with events
// departments has string parentId, string name
// On GET /departments
if (this.parentId) {
// Recursively build an array of parents
dpd.departments.get({id: parentId, $limitRecursion: 64}, function(parentDep) {
if (parentDep) {
this.parents = [parentDep.name];
if (parentDep.parents) {
this.parents = parentDep.parents.concat(this.parents);
}
@dallonf
dallonf / index.html
Created October 14, 2011 14:38
Facebook Photo Selector with Knockout.js
<!DOCTYPE html>
<html>
<head>
<title>Knockout Demo</title>
<script type="text/javascript" src="jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="jquery.tmpl.js"></script>
<script type="text/javascript" src="knockout.js"></script>
<style type="text/css">
.selected {
border: #FFFF00 3px solid;