Skip to content

Instantly share code, notes, and snippets.

View graphql.js
let rootValue = {
response: {
timing: {
fields: []
}
}
}
const start = new Date().getTime();
return graphql(schema, query, rootValue, variables).then(response => {
@eyston
eyston / controller.js
Created Jun 24, 2013
angular typeahead
View controller.js
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 Apr 8, 2011
Please help this ruby idiot mock something
View gist:910952
def MPQ path
path
end
class ReplayFile
def initailize path
@archive = MPQ(path)
end
end
View history.js
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 Oct 19, 2016
Doing onEnter hooks with Relay that require data / async
View route.js
const node = Relay.QL`
query {
node(id: $channelId) {
... on Channel {
joined
${JoinChannelMutation.getFragment('channel')}
}
}
}
`;
@eyston
eyston / gist:1061591
Created Jul 2, 2011
Example of Akka Actor Become
View gist:1061591
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
View gist:4997793
## env.rb ##
PageObject.javascript_framework = :jquery
## login.rb ##
class LoginPage
include PageObject
## stuff for every page ##
View gist:4956444
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
View 1.js
const rootValue = {
user,
client,
...root,
__timing: [] // store the timing info in here -- sorta hacky!
}
return graphql(schema, query, rootValue, variables).then(response => {
View auth.js
const hasRole = (role, next) => {
return (obj, args, ctx) => {
if (ctx.rootValue.user.hasRole(role)) {
next(obj, args, ctx);
} else {
return null;
}
}
}
You can’t perform that action at this time.