Skip to content

Instantly share code, notes, and snippets.

View zph's full-sized avatar

Zander Hill zph

View GitHub Profile
@zph
zph / saltpack.vim
Created February 15, 2019 20:30 — forked from jecxjo/saltpack.vim
Vimscript to Read/Write Keybase's Saltpack encrypted files
" Keybase - saltpack
augroup SALTPACK
au!
" Make sure nothing is written to ~/.viminfo
au BufReadPre,FileReadPre *.saltpack set viminfo=
" No other files with unencrypted info
au BufReadPre,FileReadPre *.saltpack set noswapfile noundofile nobackup
" Reading Files, assumes you can decrypt
au BufReadPost,FileReadPost *.saltpack :%!keybase decrypt
@zph
zph / gist:3e0fa3e0a4644def5a65df066668fa9f
Created November 17, 2016 03:26 — forked from drpancake/gist:9605830
Manually long-polling the Atlas ATS API (Bayeux protocol)
# Requires the 'requests' module: http://docs.python-requests.org/en/latest/
import json
import requests
URL = 'https://data.atlasats.com:4000/api'
def bayeux_call(data):
headers = {'content-type': 'application/json'}
res = requests.post(URL, data=json.dumps(data), headers=headers, verify=False) # no SSL cert check
@zph
zph / update_column_type.sql
Created September 8, 2016 21:25 — forked from mmasashi/update_column_type.sql
How to change the column type for Redshift.
BEGIN;
LOCK table_name;
ALTER TABLE table_name ADD COLUMN column_new column_type;
UPDATE table_name SET column_new = column_name;
ALTER TABLE table_name DROP column_name;
ALTER TABLE table_name RENAME column_new TO column_name;
END;
-- varchar -> integer
-- UPDATE cpvbeacon_dev SET column_new = CAST (nullif(column_name, '') AS INTEGER);
@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 / 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

Installing a Gem on Heroku from a Private GitHub Repo

Sometimes you want to use a gem on Heroku that is in a private repository on GitHub.

Using git over http you can authenticate to GitHub using basic authentication. However, we don't want to embed usernames and passwords in Gemfiles. Instead, we can use authentication tokens.

  1. Get an OAuth Token from GitHub

First you will need to get an OAuth Token from GitHub using your own username and "note"