Skip to content

Instantly share code, notes, and snippets.

let rootValue = {
response: {
timing: {
fields: []
}
}
}
const start = new Date().getTime();
return graphql(schema, query, rootValue, variables).then(response => {
@eyston
eyston / controller.js
Created June 24, 2013 17:11
angular typeahead
angular.module('ymusica').controller('AlbumSearch', ['$scope', 'Albums', 'Artists', '$q', function($scope, albums, artists, $q) {
$scope.albums = [];
$scope.artists = [];
var terms = new Rx.Subject();
$scope.searchMusic = terms.onNext.bind(terms);
terms.sample(250)
@eyston
eyston / gist:910952
Created April 8, 2011 23:58
Please help this ruby idiot mock something
def MPQ path
path
end
class ReplayFile
def initailize path
@archive = MPQ(path)
end
end
import RelayStoreData from 'react-relay/lib/RelayStoreData';
import RelayQueryPath from 'react-relay/lib/RelayQueryPath';
import printRelayQuery from 'react-relay/lib/printRelayQuery';
import {List,Map} from 'immutable';
var REMOVE_KEYS = [
'_storage'
];
@eyston
eyston / route.js
Last active October 19, 2016 13:10
Doing onEnter hooks with Relay that require data / async
const node = Relay.QL`
query {
node(id: $channelId) {
... on Channel {
joined
${JoinChannelMutation.getFragment('channel')}
}
}
}
`;
@eyston
eyston / gist:1061591
Created July 2, 2011 20:01
Example of Akka Actor Become
import akka.actor.Actor
// defining messages -- Object = singleton, case class = DTO (sorta, generally)
object Born
case class Evolve(numberOfNeighbors: Int)
object Status
// receive is the method that handles incoming messages.
// alive: Receive and dead: Receive are defining alternative ways to respond to messages
// these will be switched on during runtime
## env.rb ##
PageObject.javascript_framework = :jquery
## login.rb ##
class LoginPage
include PageObject
## stuff for every page ##
Imports System.Data.Entity
Imports System.ComponentModel.DataAnnotations
Imports System.ComponentModel.DataAnnotations.Schema
Public Class PartContext
Inherits DbContext
Public Sub New()
MyBase.New("Data Source=(local);Initial Catalog=TestDB;Trusted_Connection=True;")
End Sub
const rootValue = {
user,
client,
...root,
__timing: [] // store the timing info in here -- sorta hacky!
}
return graphql(schema, query, rootValue, variables).then(response => {
@eyston
eyston / auth.js
Last active November 5, 2015 04:08
const hasRole = (role, next) => {
return (obj, args, ctx) => {
if (ctx.rootValue.user.hasRole(role)) {
next(obj, args, ctx);
} else {
return null;
}
}
}