Skip to content

Instantly share code, notes, and snippets.

@jcarley
jcarley / query.js
Created May 9, 2017 21:20
A sample query object that uses functions to filter a collection
class Query {
constructor(coll) {
this.coll = coll;
}
getCollection() {
return this.coll;
}
@jcarley
jcarley / Dockerfile
Last active May 4, 2017 00:56
My C++ Docker based dev environment.
FROM node:7.9.0
RUN apt-get update && apt-get install -y build-essential wget curl libroot-core-dev vim
ADD bashrc /root/.bashrc
CMD "/bin/bash"
@jcarley
jcarley / README
Created November 27, 2016 17:35 — forked from scrogson/README
Use bootstrap-sass npm package with Phoenix's brunch
1) install npm packages
2) update brunch-config.js
3) remove Bootstrap from web/static/css/app.css
4) rename web/static/css/app.css to web/static/css/app.scss
5) update web/static/css/app.scss
@jcarley
jcarley / gist:d15f90433c3592bb579592bd89f2daa2
Last active November 24, 2016 13:42
Command line find and replace on Mac OSX
# Find and replace. Case insenstive. This searchs for elixir files
grep --color -Rl --include=*.{yml,exs,ex,eex} "searchstring" . | xargs sed -i "" 's/searchterm/replaceterm/g'
@jcarley
jcarley / amz.ex
Last active November 19, 2016 13:56
AWS Headers in Elixir
content_type = "quicktime/mov"
headers = %{
:"content_type" => content_type,
:"x-amz-acl" => "private",
:"x-amz-server-side-encryption" => "AES256"
}
IO.inspect headers
@jcarley
jcarley / gist:b58a287eb8e351466de12957a140aab5
Created October 10, 2016 14:53
Save public cert for a host to a file
openssl s_client -connect HOSTNAME:443 -showcerts -sess_out ~/Downloads/HOSTNAME.cert
@jcarley
jcarley / gitflow-breakdown.md
Created August 22, 2016 19:42 — forked from JamesMGreene/gitflow-breakdown.md
A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
git commit --allow-empty -m "Initial commit"
git checkout -b develop master

Connect to the remote repository

@jcarley
jcarley / get_return_args.go
Created March 23, 2016 14:39
Example of how to dynamically change the value of a reference parameter
func getReturnArg(methodWatch *MethodWatch, idx int, data interface{}, defaultValue interface{}) {
dataValue := reflect.ValueOf(data)
argsValue := reflect.ValueOf(methodWatch.ReturnArgs[idx])
if dataValue.Kind() != reflect.Ptr {
panic(errors.New("result must be a pointer"))
}
dataElem := dataValue.Elem()
#!/usr/bin/env bash
list=( $(docker-machine ls | grep Running | awk '{ print $1 }') )
for i in "${list[@]}"; do
ip=$(docker-machine ip $i)
#remove line matching ip
sudo sed -i '' '/'$ip'/d' /etc/hosts
#insert ip/host on last line
sudo sed -i -e '$a\
@jcarley
jcarley / docker-machine-update-hosts.sh
Created January 28, 2016 15:19 — forked from ianlintner-wf/docker-machine-update-hosts.sh
A basic shell script to use a configuration file to update local development hosts ip running on docker-machine (virtual box) and Mac OSX
#!/usr/bin/env bash
#Usage docker-machine-update-hosts.sh hosts.conf default
#arg1 is a configuration file with hosts
#arg2 is the docker-machine name e.g. default
DOCKER_IP=$(docker-machine ip $2)
echo "$2 ip: $DOCKER_IP"
#Remove existing lines from hosts
while IFS='' read -r line || [[ -n "$line" ]]; do