Skip to content

Instantly share code, notes, and snippets.

View parkerproject's full-sized avatar

Parker parkerproject

View GitHub Profile
@parkerproject
parkerproject / index.html
Created August 17, 2016 23:41 — forked from mbajur/index.html
Working example of window.postMessage used for sending data from popup to parent page (works in IE)
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Index</title>
<script type="text/javascript">
window.open ("popup.html","mywindow", "width=350,height=250");
// Create IE + others compatible event handler
@parkerproject
parkerproject / redux-form-tut.js
Created August 18, 2016 18:47 — forked from dmeents/redux-form-tut.js
The source code for the redux form tutorial on davidmeents.com
import React, { Component } from 'react';
import { Field, reduxForm } from 'redux-form';
import { connect } from 'react-redux';
import * as actions from '../../actions';
const form = reduxForm({
form: 'ReduxFormTutorial',
validate
});
@parkerproject
parkerproject / .babelrc
Created August 25, 2016 16:48 — forked from Calamari/.babelrc
Webpack, Karma, jasmine, react Boilerplate
{
"presets": ["es2015", "react"],
"plugins": [
"add-module-exports",
"transform-object-rest-spread",
"transform-class-properties",
"transform-flow-strip-types"
]
}
@parkerproject
parkerproject / gist:9a7576eaed6924a3a7055732c504cd9b
Created September 20, 2016 21:11 — forked from eshiota/gist:4130937
Testing form submission with jQuery and Jasmine
// sizeSelectionModule and addToCartModule are local variables that
// act as shortcuts to their namespaces
describe("when add to cart form is submitted", function () {
var $form;
beforeEach(function () {
// We use div instead of form so we can just mock the submit behavior
$form = $("<div />");
});
@parkerproject
parkerproject / index.js
Created September 23, 2016 05:45 — forked from waltcow/index.js
Example with react-native-gifted-listview and redux implementation
import React, {Component, PropTypes} from "react";
import {View, ListView, Text, NetInfo, TouchableHighlight, Image} from "react-native";
import Icon from 'react-native-vector-icons/Ionicons'
import GiftedListView from 'react-native-gifted-listview'
import GiftedSpinner from 'react-native-gifted-spinner'
import Animatable from 'react-native-animatable'
import Swipeout from 'react-native-swipeout'
@parkerproject
parkerproject / 1-react-native-simulator-and-device.md
Created September 30, 2016 17:26 — forked from almost/1-react-native-simulator-and-device.md
Test React Native on the simulator and on a device without editing the code each time!

In the default React Native app scaffolding you have to edit AppDelegate.m to change where it loads the code if you want to test on your device. I use the following snippet to detect if it's being compiled for Debug or Production and for the Simulator or a device. For Production it uses a copy of the code included in the bundle, for Debug on the simualtor it loads from a server on localhost and for Debug on a device it loads from a server on a given IP address.

NOTE: You need to edit YOUR-IP-HERE and change it to the IP to load the code from when in Debug mode on a device. You could use a service like ngrok to make this work from anywhere.

  NSURL *jsCodeLocation;

  // Loading JavaScript code
  #if DEBUG
    // For Debug build load from development server. Start the server from the repository root:
@parkerproject
parkerproject / gist:6a55c56b52571026478710abfb08c1cb
Created December 2, 2016 19:40
Simple node.js code style tips to improve code quality

Whether you use 2 spaces or 4 spaces, there are a few simple things that can make your node.js code easier to read. We've been using them in all the hapi modules for over 4 years now to great results. This list is by no means complete but it highlights the most useful elements that will give you immediate value in reducing bugs.

Required modules

JavaScript makes it harder than most languages to know where variables are coming from. Variables assigned required modules are particularly important because they represent a singleton object shared with the entire application. There are also globals and module globals, along with function variables and arguments.

Traditionally, variables starting with an uppercase letter represent a class that must be instantiated using new. This was an important semantic in the early days of JavaScript but at this point, if you don't know Date requires new Date() you are probably very new. We have adopted Upper Camel Case variable names for all module global variables

@parkerproject
parkerproject / proxy.js
Created December 8, 2016 20:43 — forked from gouroujo/proxy.js
Proxy on /api for express app using node http-proxy
import { createProxyServer } from 'http-proxy';
import url from 'url';
import _ from 'lodash';
module.exports = app => {
const proxy = createProxyServer();
app.all('/api/v1/*', (req, res) => {
const path = _.drop(req.url.split('/'), 3);
proxy.proxyRequest(req, res, {
target: url.resolve('YOUR URL', path.join('/')),
@parkerproject
parkerproject / tabs.js
Created December 20, 2016 17:47 — forked from hong6/tabs.js
<style>
.wrapper {width: 600px; margin: 20px auto; }
ul.tabs {float: left; width: 200px; }
</style>
<div class="wrapper">
<ul class="tabs">
<li><a href="#gallery">Gallery</a></li>
<li><a href="#submit">Submit</a></li>