Skip to content

Instantly share code, notes, and snippets.

View arunoda's full-sized avatar
👨‍🍳
Cooking something new

Arunoda Susiripala arunoda

👨‍🍳
Cooking something new
View GitHub Profile
var Lokka = require('lokka').Lokka;
var Transport = require('lokka-transport-http').Transport;
// Create a lokka client against SWAPI GraphQL API
var client = new Lokka({
transport: new Transport('http://graphql-swapi.parseapp.com/')
});
var graphqlDemo = React.createClass({
getInitialState() {
return {movies: []}
},
componentDidMount() {
// query when we mount the view
client.query(`
{
allFilms {
films {
import Lokka from 'lokka';
import HttpTransport from 'lokka-transport-http';
const client = new Lokka({
transport: new HttpTransport('http://graphql-swapi.parseapp.com/')
});
@arunoda
arunoda / graphql-cache-demo.js
Last active November 25, 2015 15:39
This is a demo of how to write a simple app with our GraphQL Cache.
const GraphQLCache = require('graphql-cache');
const HttpTransport = require('graphql-cache-http-transport');
const React = require('react');
const ReactDOM = require('react-dom');
const Cache = new GraphQLCache({
transport: new HttpTransport('/graphql');
});
// Create the fragment where we can use later on
@arunoda
arunoda / notes.md
Created October 14, 2015 19:48 — forked from widged/notes.md
GraphQL links. Articles to read and code to check.
var graphql = require('graphql');
var userType = new graphql.GraphQLObjectType({
name: 'User',
fields: () => ({
id: {type: graphql.GraphQLString},
name: {type: graphql.GraphQLString},
friends: {
type: new graphql.GraphQLList(userType),
args: {
ServiceConfiguration.configurations.remove({
service: "meteor-developer"
});
if(Meteor.settings.meteorDevelopers) {
var meteorDevelopersInfo = Meteor.settings.meteorDevelopers;
} else {
var meteorDevelopersInfo = {
clientId: "HcempmSyaawiyb4G4",
secret: "snC3snsmTebC8HHCwwhqhHaAzAFxtFsQRL"
{
_id: "7Tij2HTGqhrRE3k78",
created: ISODate("2014-02-07T04:04:33.266Z"),
initialDataReceived: true,
name: "kadira-ui",
owner: "vapXLdykrravRPua8",
secret: "bfda539b-cf42-469a-9847-49f11883858f",
plan: "pro",
planToUSD: 0.003,
collaborators: [],
# add the email package
meteor add email

The prep-script.sh will setup the latest Node and install the latest perf version on your Linux box.

When you want to generate the flame graph, run the following (folder locations taken from install script):

sudo sysctl kernel/kptr_restrict=0

perf record -i -g -e cycles:u -- ~/sources/node/node --perf-basic-prof script.js

perf script | egrep -v "( __libc_start| LazyCompile | v8::internal::| Builtin:| Stub:| LoadIC:|\[unknown\]| LoadPolymorphicIC:)" | sed 's/ LazyCompile:[*~]\?/ /' | ~/sources/FlameGraph/stackcollapse-perf.pl > out.perf-folded