Skip to content

Instantly share code, notes, and snippets.

View zph's full-sized avatar

Zander Hill zph

View GitHub Profile
@zph
zph / doc.md
Created August 13, 2016 03:03 — forked from oelmekki/doc.md
Rails + Browserify + React + es7

1. Gemfile

gem 'browserify-rails', '1.5.0' # until fix: https://github.com/browserify-rails/browserify-rails/issues/101
gem 'react-rails'

Browserify-rails allows to use browserify within assets pipeline. React-rails is here only to allow to use #react_component (and thus, prerendering).

Note that jquery-rails can be removed from Gemfile, the npm version of jquery and jquery-ujs will be used instead.

@zph
zph / re-run
Last active July 19, 2016 16:33
#!/usr/bin/env bash
if [[ ! -x $(which fswatch) ]];then
echo "Must install fswatch"
exit 1
fi
main(){
DIR_OR_FILE=$1
shift
#!/usr/bin/env bash
set -eou pipefail
install_aws(){
local tmpdir="$1"
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "$tmpdir/awscli-bundle.zip"
cd $tmpdir
unzip $tmpdir/awscli-bundle.zip
python $tmpdir/awscli-bundle/install -b ~/bin/aws
package main
import (
"crypto/md5"
"fmt"
"io/ioutil"
)
func fileMD5(file string) string {
fileName := file
@zph
zph / deploy_dokku.md
Created May 31, 2016 05:46 — forked from nhu313/deploy_dokku.md
Deploying phoenix on Dokku through Digital ocean

This write up was based on Henrik's gist

Create server

  1. Create a droplet on digital ocean. Use my referal link for $10 credit. I also credit if you spend money, so thanks in advance ;)
    1. Select "Create Droplet"
    2. Under "Choose an image", click on "One-click Apps"
    3. Select Dokku for your app
    4. Under "Choose a size" select at least 1GB of RAM
    5. Add your ssh public key
  2. Click "Create"
@zph
zph / README.md
Created May 31, 2016 05:43 — forked from joakimk/README.md
CircleCI elixir build example

This runs a build for a small elixir (phoenix) project in about 40 seconds by caching as much of the compiled files as possible.

We've been using this for months in multiple projects without any issues. Please ping be if there is any issues with this script and I'll update it.

It should be generic enough to work on any elixir app using mix.

If you have a elixir_buildpack.config, then enable that section in the build script to keep versions in sync!

@zph
zph / drain_stop.ex
Created May 29, 2016 11:08 — forked from aaronjensen/drain_stop.ex
Phoenix Drain Stop
defmodule DrainStop do
@moduledoc """
DrainStop Attempts to gracefully shutdown an endpoint when a normal shutdown
occurs. It first shuts down the acceptor, ensuring that no new requests can be
made. It then waits for all pending requests to complete. If the timeout
expires before this happens, it stops waiting, allowing the supervision tree
to continue its shutdown order.
DrainStop should be installed in your supervision tree *after* the
EndPoint it is going to drain stop.
@zph
zph / .powenv
Created May 25, 2016 03:46 — forked from dre1080/.powenv
Using Pow!! with Foreman (Configuration)
# In your app's root.
# Make Pow!! export all the env variables contained in the .env file used by Foreman.
export $(cat .env)
@zph
zph / ngrok-selfhosting-setup.md
Created May 19, 2016 04:29 — forked from lyoshenka/ngrok-selfhosting-setup.md
How to setup Ngrok with a self-signed SSL cert

Intro

The plan is to create a pair of executables (ngrok and ngrokd) that are connected with a self-signed SSL cert. Since the client and server executables are paired, you won't be able to use any other ngrok to connect to this ngrokd, and vice versa.

DNS

Add two DNS records: one for the base domain and one for the wildcard domain. For example, if your base domain is domain.com, you'll need a record for that and for *.domain.com.

Different Operating Systems

@zph
zph / Main.elm
Last active November 6, 2015 14:58
module Main (main) where
import Html exposing (Html)
import Html.Attributes as Attributes
import String as S
fizz : Int -> Bool
fizz i = (0 == i % 3)
buzz : Int -> Bool