Skip to content

Instantly share code, notes, and snippets.

View jimthedev's full-sized avatar

Jim Cummins jimthedev

View GitHub Profile
@jimthedev
jimthedev / app.js
Last active September 1, 2016 21:37
Express with vhost and http proxy support
/**
* The following is an example of how to use virtual hosts in Express.
* Additionally, there is an example of using virtual hosts with an http
* proxy. This means that this config itself defines 4 express apps.
*
* Why 4?
* For vhosts to work in express, you need to define a parent express app
* (in our case that is `app`) and child express apps (`portfolioapp`,
* `demoapp`, and `finalapp`). portfolioapp is just a regular express
* app that is displayed at the domain root.
@jimthedev
jimthedev / app.js
Created September 1, 2016 15:04
simple node static server
var fs = require("fs");
var host = "0.0.0.0";
var port = 80;
var express = require("express");
var app = express();
app.use(express.static(__dirname + "/public")); //use static files in ROOT/public folder
app.listen(port, host);
@jimthedev
jimthedev / .env
Created August 11, 2016 12:51
dokku rethink provision script
ROOT_IP=
ROOT_DOMAINNAME=
DO_KEY_READ=
DO_KEY_WRITE=
@jimthedev
jimthedev / nvm-node-on-do-dokku-debian.md
Created August 9, 2016 14:33
Nvm-node-on-do-dokku-debian
sudo apt-get update && sudo apt-get install build-essential libssl-dev
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.4/install.sh | bash

You will likely get an error during install. Don't worry, it took but you need to change your bashrc file slightly. Add the following line to the bottom of /home/dokku/.bashrc:

source ~/.nvm/nvm.sh
@jimthedev
jimthedev / howto.md
Last active January 22, 2019 18:54
digital ocean, dokku, rethinkdb, lets encrypt, horizon

NOTE: THESE ARE INCOMPLETE AND THE STEPS LISTED HERE WILL ABSOLUTELY LEAVE YOU VULNERABLE TO ATTACK. THIS IS WORK IN PROGRESS AS I WORK ON HARDENING THE SERVER

Overview

The following are steps to help you configure and run your own Heroku-like server which can support multiple Horizon.io / RethinkDB applications including support for Lets Encrypt (SSL) on Digital Ocean.

Limitations

Recommend keeping your domain scheme to subdomain.domain.com and no deeper. If you try to go further then it makes Let's Encrypt a little trickier.

@jimthedev
jimthedev / .zshrc-partial
Created July 27, 2016 22:17
.zshrc fun with hub, git, npm, react, hjs-webpack
# Creates a git and github repo in the projects folder
# and changes the current directory to it
proj() {
echo "Changing directory to ~/projects"
cd ~/projects
echo "Creating directory for project"
mkdir -p "$@"
echo "Changing directory to ~/projects/$@"
cd $@
echo "Creating git repo"
@jimthedev
jimthedev / .zshrc
Created July 24, 2016 17:22
Hacky first attempt at create-react-app but for https://github.com/HenrikJoreteg/hjs-webpack
# Creates a git and github repo in the projects folder
# and changes the current directory to it
proj() {
echo "Changing directory to ~/projects"
cd ~/projects
echo "Creating directory for project"
mkdir -p "$@"
echo "Changing directory to ~/projects/$@"
cd $@
echo "Creating git repo"
@jimthedev
jimthedev / index.js
Last active July 6, 2016 03:57
requirebin sketch
var mobx = require('mobx');
var _ = require('lodash');
/*
MOBX in VANILLA ES5
Notes are based on Matt Ruby's Open Source North Talk:
Practical React with MobX
https://www.youtube.com/watch?v=XGwuM_u7UeQ
@jimthedev
jimthedev / reduceOrientation.js
Created February 17, 2016 22:36
Reduce orientation events coming from react-native-orientation npm module
function _reduceOrientation(lastOrientation, orientation) {
if(orientation==='UNKNOWN' && lastOrientation==='UNKNOWN') {
return 'UNKNOWN';
}
switch(orientation) {
case 'LANDSCAPE':
case 'PORTRAIT':
return orientation;
@jimthedev
jimthedev / ionic-toggle-platform-bookmarklet.js
Last active December 7, 2015 18:54
Ionic2 page reload bookmarklet to toggle between ionic platforms
javascript:void((function(){var loc = location.href; var base = loc.split('?')[0]; loc.indexOf("?") == -1 || loc.indexOf("?ionicplatform=ios") > -1 ? (location.href = base+"?ionicplatform=android") : (location.href = base+"?ionicplatform=ios");})());