Skip to content

Instantly share code, notes, and snippets.

View parkerproject's full-sized avatar

Parker parkerproject

View GitHub Profile
@parkerproject
parkerproject / index.js
Created March 23, 2018 19:43 — forked from srph/index.js
reactjs: an example of a high-order component useful for simple pagination.
import React, {PropTypes} from 'react';
import axios from 'axios';
/**
* This is a high-order component for Components
* for pages with pagination.
*
* #FEATURES:
* - Pages (list pages) are easier to test!
* - Fetching the data is a no-brainer
@parkerproject
parkerproject / user.js
Created March 15, 2018 02:51 — forked from bulkan/user.js
Mocking Sequelize model function
var Promise = require('bluebird');
var sinon = require('sinon');
var User = require('./db/models').User;
describe('User model', function(){
var userFindStub;
var sandbox;
before(function(){
sandbox = sinon.sandbox.create();
@parkerproject
parkerproject / doSynchronousLoop.js
Created March 10, 2018 19:14 — forked from steve-taylor/doSynchronousLoop.js
Synchronous for loop in JavaScript to ensure that the n+1th item isn't processed until the callback of the nth item's processor has been called.
/**
* Process an array of data synchronously.
*
* @param data An array of data.
* @param processData A function that processes an item of data.
* Signature: function(item, i, callback), where {@code item} is the i'th item,
* {@code i} is the loop index value and {@code calback} is the
* parameterless function to call on completion of processing an item.
*/
function doSynchronousLoop(data, processData, done) {
@parkerproject
parkerproject / curry.es6.js
Created March 10, 2018 16:15 — forked from nathggns/curry.es6.js
Recursive curry functions in ES6
function curry(fn, ...args) {
if (args.length === fn.length) {
return fn(...args);
}
return curry.bind(this, fn, ...args);
}
function add(a, b) {
return a + b;
@parkerproject
parkerproject / apollo-server-tutorial-schema.js
Created February 28, 2018 04:38 — forked from helfer/apollo-server-tutorial-schema.js
The full schema for the GraphQL server tutorial
import { makeExecutableSchema } from 'graphql-tools';
const typeDefs = `
type Author {
id: Int
firstName: String
lastName: String
posts: [Post]
}
type Post {
@parkerproject
parkerproject / add-upstream.md
Created February 6, 2018 16:57
So you've forked a Repository and you want updates...

#tl;dr

setting up a branch to track a repo

pre: assuming you have forked a repo and cloned your fork to your computer

  1. git remote add [maintainer's name] [paste URL here]
  2. git fetch --all
  3. git branch --track [maintainer's name]_[branch] [remote name from step 1]/[branch you want to track] At this point you may watch to checkout to your newly create branch and issue a git pull command.
@parkerproject
parkerproject / add-upstream.md
Created February 6, 2018 16:57
So you've forked a Repository and you want updates...

#tl;dr

setting up a branch to track a repo

pre: assuming you have forked a repo and cloned your fork to your computer

  1. git remote add [maintainer's name] [paste URL here]
  2. git fetch --all
  3. git branch --track [maintainer's name]_[branch] [remote name from step 1]/[branch you want to track] At this point you may watch to checkout to your newly create branch and issue a git pull command.
async.each(urls, function(url, callback){
console.log("Grabbing Dataset from " + url);
makeRequest(url, function(){
callback();
});
}, function(err){
console.log("Hello");
if(err){
console.log("Error grabbing data");
} else {
@parkerproject
parkerproject / firebase_detect_data.js
Created June 12, 2017 17:30 — forked from anantn/firebase_detect_data.js
Firebase: Detecting if data exists. This snippet detects if a user ID is already taken
function go() {
var userId = prompt('Username?', 'Guest');
checkIfUserExists(userId);
}
var USERS_LOCATION = 'https://SampleChat.firebaseIO-demo.com/users';
function userExistsCallback(userId, exists) {
if (exists) {
alert('user ' + userId + ' exists!');
// recieve message
// event object contains:
// - data: message sent
// - origin (host from which the message was sent, e.g. http://blah.example.com)
// - source (reference to a Window object from which message was sent)
function postMessageHandler( event ) {
console.log("We've got a message!");
console.log("* Message:", event.data);
console.log("* Origin:", event.origin);
console.log("* Source:", event.source);