Skip to content

Instantly share code, notes, and snippets.

View BrianSigafoos's full-sized avatar

Brian Sigafoos BrianSigafoos

View GitHub Profile
@BrianSigafoos
BrianSigafoos / stimulus.md
Created September 20, 2019 15:33 — forked from mrmartineau/stimulus.md
Stimulus cheatsheet
@BrianSigafoos
BrianSigafoos / reload-db.sh
Created August 28, 2019 14:31
Reload database
#!/bin/sh
DB_DUMP=$HOME/<filename>.dump
DB_NAME=<db name>
if [ -f $DB_DUMP ]; then
echo Creating database: $DB_NAME
createdb $DB_NAME > /dev/null 2>&1
if [ "$?" != "0" ]; then
@BrianSigafoos
BrianSigafoos / nginx_source_pagespeed_passenger_ubuntu.md
Created June 23, 2019 15:52 — forked from benbonnet/nginx_source_pagespeed_passenger_ubuntu.md
nginx from source with pagespeed and passenger on ubuntu 16.04 and above
sudo apt-get -y update
sudo apt-get install -y build-essential libcurl4-openssl-dev unzip software-properties-common git libpcre3-dev libpcre3

adding zlib, openssl and pcre

cd && mkdir sources && cd sources
wget https://downloads.sourceforge.net/project/pcre/pcre/8.41/pcre-8.41.tar.gz && tar xzvf pcre-8.41.tar.gz
@BrianSigafoos
BrianSigafoos / db.rake
Created May 9, 2019 13:32 — forked from khalilgharbaoui/db.rake
Rails rake tasks for dump & restore of PostgreSQL databases
# Original source: https://gist.github.com/hopsoft/56ba6f55fe48ad7f8b90
# Merged with: https://gist.github.com/kofronpi/37130f5ed670465b1fe2d170f754f8c6
# Benefits of: https://gist.github.com/e12e/e0c7d2cc1d30d18c8050b309a43450ac
# And fixes of: https://gist.github.com/joelvh/f50b8462611573cf9015e17d491a8a92
namespace :db do
desc 'Dumps the database to backups'
task dump: :environment do
dump_fmt = ensure_format(ENV['format'])
dump_sfx = suffix_for_format(dump_fmt)
backup_dir = backup_directory(Rails.env, create: true)
@BrianSigafoos
BrianSigafoos / aws_create_users_ubuntu.sh
Created February 4, 2019 15:43 — forked from vasansr/aws_create_users_ubuntu.sh
AWS User Data Script to create users when launching an Ubuntu server EC2 instance
#!/bin/bash
#
# Initial script to create users when launching an Ubuntu server EC2 instance
#
declare -A USERKEY
#
# Create one entry for every user who needs access. Be sure to change the key to their
# Remove local branches that have gone remotes - https://stackoverflow.com/a/33548037/967115
git fetch -p && for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done
@BrianSigafoos
BrianSigafoos / capybara.md
Created August 31, 2017 20:55 — forked from remi/capybara.md
RSpec Matchers

Capybara

save_and_open_page

Matchers

have_button(locator)
@BrianSigafoos
BrianSigafoos / README.md
Created August 24, 2017 18:54 — forked from joyrexus/README.md
curl tutorial

An introduction to curl using GitHub's API.

Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin

Includes HTTP-Header information in the output

@BrianSigafoos
BrianSigafoos / curl_bash.md
Created August 24, 2017 16:55
curl + REST API

curl testing a REST API

# HEAD request: -I 
$ curl -I  http://0.0.0.0:3000/posts

# -i (--include) protocol headers and -X (--request) for GET, PUT, DELETE
$ curl -i -X HEAD http://0.0.0.0:3000/posts

# prettify JSON results with python -mjson.tool 
$ curl ... | python -mjson.tool
@BrianSigafoos
BrianSigafoos / model_validations.md
Created August 22, 2017 17:56
Rails model layout and validations

Model layout & validations

class User < ActiveRecord::Base
  # keep the default scope first (if any)
  default_scope { where(active: true) }

  # constants come up next
  COLORS = %w(red green blue)

  # afterwards we put attr related macros