Skip to content

Instantly share code, notes, and snippets.

View justin808's full-sized avatar
💭
Hiring!

Justin Gordon justin808

💭
Hiring!
View GitHub Profile
var longFn = function(x) {
return new Promise(function(res, rej) {
if (x) {
setTimeout(res(x), 1000);
} else {
rej("ERROR from not passing in a value to longFn");
}
});
};
@justin808
justin808 / Gemfile
Created November 12, 2015 22:11
Octopress 3 Gemfile
source "https://rubygems.org"
gem "octopress", "~>3"
gem "jekyll", "<3"
group :jekyll_plugins do
gem "octopress-asset-pipeline"
end
@justin808
justin808 / rails_helper.rb
Created September 7, 2015 04:16
rails_helper with setup for Capybara feature tests, allowing JavaScript driver to be set by setting DRIVER environment variable.
ENV["RAILS_ENV"] ||= "test"
require File.expand_path("../../config/environment", __FILE__)
require "rspec/rails"
require "rspec/mocks"
require "capybara/rspec"
require "vcr"
require "rails/application"
require "webmock/rspec"
require "shoulda/matchers"
require "capybara-screenshot/rspec"
@justin808
justin808 / check_db_version.rb
Created September 6, 2015 23:44
Check DB Version -- place this in config in your Rails app to ensure the team uses the same db version. Change line to match your expected DB.
# Method to check the DB version matches
# We ran into an issue where different versions of postgres caused inconsistent results.
def check_db_version
expected_db_version = "PostgreSQL 9.4"
adapter = ActiveRecord::Base.connection.adapter_name
sql = case adapter
when "MSSQL"
"SELECT @@VERSION"
when "MySQL", "Mysql2", "PostgreSQL"
"SELECT VERSION()"
@justin808
justin808 / bundle-global.js
Created July 17, 2015 08:15
Simplest Hello World Webpack output with global export
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
@justin808
justin808 / bundle.js
Created July 17, 2015 08:12
Simplest Hello World Webpack output
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
@justin808
justin808 / .tmux.conf
Created July 6, 2015 23:55
.tmux.conf
set-option -g default-shell /bin/zsh
# https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard
# http://brentvatne.github.com/tmux-copy-paste/
# this next command takes the current buffer and puts it on the OS clipboard
#bind Y run "tmux save-buffer - | reattach-to-user-namespace pbcopy"
#
# I don't understand why the next would be useful
# bind P run "tmux paste-buffer"
bind y copy-mode
@justin808
justin808 / pgk.zsh
Last active April 10, 2017 23:04
Script to kill errant rails development processes
export PROCESSES_TO_QUIT='bpos puma rake sidekiq spring rails$ ruby-debug phantomjs zeus passenger guard resque "node server.js" ruby$ node foreman fsevent_wat'
pgr() {
echo "Finding processes in list: $PROCESSES_TO_QUIT"
echo $PROCESSES_TO_QUIT | xargs -n 1 pgrep -l
}
pgk() {
echo "Killing processes in list: $PROCESSES_TO_QUIT"
echo $PROCESSES_TO_QUIT | xargs -n 1 pkill -l
@justin808
justin808 / railsonmaui-rails.zsh
Last active August 29, 2015 14:20
Rails Zsh Scripts
# Kill stuff
pgr() {
for x in rake spring rails ruby-debug phantomjs zeus passenger guard resque "node server.js"; do
pgrep -fl $x;
done
}
pgk() {
for x in rake spring rails ruby-debug phantomjs zeus passenger guard resque "node server.js"; do