Skip to content

Instantly share code, notes, and snippets.

View joshbedo's full-sized avatar
🤙

Josh Bedo joshbedo

🤙
View GitHub Profile
@joshbedo
joshbedo / s3multipart.js
Created August 13, 2015 11:57
S3 multipart upload with NodeJS
var express = require('express')
var app = express()
var AWS = require('aws-sdk');
var bodyParser = require('body-parser');
var fs = require('fs');
var zlib = require('zlib'); // gzip compression
var multiparty = require('connect-multiparty'),
multipartyMiddleware = multiparty();
@joshbedo
joshbedo / sailsjs_nginx
Created August 17, 2015 14:12
Nginx config for Node.js and Websockets
# Load balancer configuration
upstream exampleApp {
# Directs to the process with least number of connections.
least_conn;
# One failed response will take a server out of circulation for 20 seconds.
server 127.0.0.1:10080 fail_timeout=20s;
#server 127.0.0.1:10081 fail_timeout=20s;
#server 127.0.0.1:10082 fail_timeout=20s;
#server 127.0.0.1:10083 fail_timeout=20s;
@joshbedo
joshbedo / 1-react-native-simulator-and-device.md
Created December 18, 2015 06:08 — 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:
@joshbedo
joshbedo / proxy.js
Created December 19, 2015 08:22
Docker proxy
//var GUEST_URL = process.env['DOCKER_HOST'].substring(0, guestPortIndex);
console.log(proxy.createServer({
target : 'http://192.168.99.100',
ws: true
}).listen(2376));
@joshbedo
joshbedo / renderSceneFix
Created January 8, 2016 00:04
fix renderScene
renderScene(route, navigator) {
if (route && route.component) {
let Component = route.component;
return (
<Component navigator={navigator} route={route} />
)
}
switch (this.state.currentRoute) {
case 'LOGIN_STATE_LOGOUT':
@joshbedo
joshbedo / handlers.js
Created June 1, 2017 21:57
Checkout Route Handlers
import Joi from 'joi';
import {sanitizeEmailAddress} from '../../core/email';
import {ErrorName} from '../../core/errors';
import {BadRequest} from '../../core/responses';
import {hasKeys} from '../../core/utils';
import {Cart} from '../carts/models';
import log from './logging';
import {Checkout} from './models';
@joshbedo
joshbedo / model.js
Created June 1, 2017 21:59
Checkout Model
import {Decorators as DBDecorators} from '../../core/db';
import {PermissionDenied} from '../../core/errors';
import {Cart} from '../carts/models';
import {CartSerializer} from '../carts/serializers';
import {User} from '../users/models';
import log from './logging';
const tables = {
Checkout: 'Checkouts'
@joshbedo
joshbedo / Routes.js
Created June 1, 2017 22:01
Checkout Routes
import Joi from 'joi';
import routePrerequisites from './routePrerequisites';
// Data schemas
import {CheckoutSerializer} from './serializers';
// API endpoint handlers
import {
CheckoutsHandler,
CheckoutIdHandler
} from './handlers';
@joshbedo
joshbedo / react.redux.js
Created June 1, 2017 22:08
React/Redux
/**
* Actions
**/
import {
VEHICLE_MAKE_CHANGED,
VEHICLE_MODEL_CHANGED,
VEHICLE_ADD_REQUEST,
VEHICLE_ADD_SUCCESS,
VEHICLE_ADD_ERROR
} from './types';
@joshbedo
joshbedo / git.migrate
Created August 19, 2020 17:32 — forked from niksumeiko/git.migrate
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.