Skip to content

Instantly share code, notes, and snippets.

View kylewelsby's full-sized avatar
🎯
Focusing

Kyle Welsby kylewelsby

🎯
Focusing
View GitHub Profile
@ChuckJHardy
ChuckJHardy / example_activejob.rb
Last active June 28, 2024 12:52
Example ActiveJob with RSpec Tests
class MyJob < ActiveJob::Base
queue_as :urgent
rescue_from(NoResultsError) do
retry_job wait: 5.minutes, queue: :default
end
def perform(*args)
MyService.call(*args)
end
@hcurotta
hcurotta / post-merge
Created October 17, 2014 14:34
Post Merge git hook to trigger codeship deployment when using BitBucket
#!/bin/bash
branch_name=$(git symbolic-ref --short HEAD)
if [ "$branch_name" == 'dev' ] || [ "$branch_name" == 'staging' ]
then
git commit --allow-empty -m 'empty commit to trigger deployment'
fi
@DerLobi
DerLobi / pre-commit
Last active May 9, 2022 09:45
Don't commit focused tests. Use this as a pre-commit hook and the commit won't succeed if you have staged changes that contain `fdescribe`, `fcontext`, `fit`, `fspecify` or `fexample`. Copy this file as `pre-commit` into the `.git/hooks` folder of your repository (create it if neccessary) and chmod +x the file.
#!/bin/sh
#
# This pre-commit hook looks for `fdescribe`, `fcontext`, `fit`, `fspecify` and `fexample` in the
# staged files and exits with an error code of 1 if there are such changes.
#
STATUS=0
DESCRIBEFILES=$(git diff --staged -G"^\s*fdescribe\(" --name-only | wc -l)
if [ $DESCRIBEFILES -gt 0 ]
@schinckel
schinckel / install.sh
Last active August 9, 2017 18:01 — forked from bradrydzewski/install.sh
Drone.io Install Postgres9.4
#!/bin/bash
# remove existing 9.3 installation
sudo /etc/init.d/postgresql stop
sudo apt-get --force-yes -fuy remove --purge postgresql postgresql-9.1 postgresql-client
# install 9.4
sudo apt-get install python-software-properties
sudo add-apt-repository 'deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main 9.4'
sudo apt-get update
@kylewelsby
kylewelsby / bugsnag_phantomjs.js
Last active December 31, 2015 20:09
A useful bit of code to be able to report PhantomJS errors to BugSnag
/* global require, phantom */
(function () {
'use strict';
var exec, system, env;
exec = require('child_process').spawn;
system = require('system');
env = system.env.NODE_ENV || system.env.RACK_ENV || 'development';
phantom.onError = function (message, trace) {
// dont report for development
if (env === 'development') {
@leehambley
leehambley / AAAS.md
Last active December 31, 2015 02:59
Authorisation as a service?

Problem

Web applications need understand what permissions are granted to a current user in two key areas.

  1. When enforcing the permission server side (e.g returning 403 when trying to access a resource outside of one's graph)
  2. When rendering the user interface, so as not to render misleading controls (e.g "Edit this Widget", if the user lacks the appropriate permissions.

Further, in many applications in the wild (for better, or worse, perhaps I need new friends and colleagues) I've seen ways implementd to nerf or flat-out disable authorisation controls. In addition to the regular graph-based authorisation flow, the concept of super users is prevelant, and dangerous.

Background

@mtnygard
mtnygard / jenkins.json
Last active October 14, 2019 09:35
Packer.io template for a Jenkins server
{
"builders": [{
"type": "amazon-ebs",
"access_key": "",
"secret_key": "",
"region": "us-east-1",
"source_ami": "ami-de0d9eb7",
"instance_type": "m1.large",
"ssh_username": "ubuntu",
"ami_name": "packer-jenkins {{.CreateTime}}"
.run(['$cookies', 'user', 'forge', function($cookies, user, forge){
//Check for cookies.
var token = $cookies["X-Shrug-Token"];
if( token ) {
forge.sessions.get({id: token},
function success(data) {
user.login(data);
},
function error() {
@adharris
adharris / postgres_array.go
Created November 28, 2012 19:52
PostgreSQL demo of Array types using Golang
package main
import (
"database/sql"
"errors"
"fmt"
_ "github.com/bmizerany/pq"
"os"
"regexp"
"strings"