Skip to content

Instantly share code, notes, and snippets.

@davidoram
davidoram / test_specs.sh
Last active September 10, 2015 01:02
Given a list of specs, run one test together with each in the list
#!/bin/bash
#
# Run a failing spec in combination with each other spec and record which combinations cause a failure
#
# Put a list of all specs into specs.txt
# eg: $ $ find spec -name '*_spec.rb' -print > specs.txt
# Set the failingspec variable below
# Set the seed variable below
#
# Writes a log to testspec.log, which is formatted as follows:
@davidoram
davidoram / ctags-rails.sh
Last active March 2, 2020 10:33
Shell script to build ctags for rails project, with details on how to configure your Atom editor to use
#!/bin/bash
#
# Generate the ctags for a rails/ruby project in the following files:
#
# .tags contains the tags for the project itself
# .tags_bundler contains the tags for all libraries
#
# The idea is your editor can rebuild the .tags file on file save
# which should be quite quick
#
@davidoram
davidoram / gist:4c9b1d2648e3e3ed5182
Created January 27, 2016 03:30
Print FB callstck in a method - drop this code in a method
puts " -- > called blah_blah_method"
puts caller.select{ |f| f =~ /flybuys/ }
@davidoram
davidoram / gist:4eff788c3037d0ca358d
Created March 6, 2016 22:45
Snippet to find Sidekiq workers in the Retry queue, of a given worker type
query = Sidekiq::RetrySet.new
callbacks = query.select {|j| j.klass == 'CallbackNotificationWorker' }
VAGRANT_LOG=info vagrant init ubuntu/trusty64
INFO global: Vagrant version: 1.8.5
INFO global: Ruby version: 2.2.3
INFO global: RubyGems version: 2.4.5.1
INFO global: VAGRANT_LOG="info"
INFO global: VAGRANT_EXECUTABLE="/opt/vagrant/embedded/gems/gems/vagrant-1.8.5/bin/vagrant"
INFO global: VAGRANT_OLD_ENV_VAGRANT_LOG="info"
INFO global: VAGRANT_OLD_ENV_TERM="xterm-256color"
INFO global: VAGRANT_OLD_ENV_SSH_AUTH_SOCK="/private/tmp/com.apple.launchd.Kfz21yAIM0/Listeners"
INFO global: VAGRANT_OLD_ENV_LOGNAME="davidoram"
@davidoram
davidoram / unix-socket-to-tcp.sh
Created May 22, 2018 03:43
Create a UNIX socket connected to a TCP socket. Useful for connecting a rails app to a postgres instance that has been dockerized
#!/bin/bash
set -e
if [ $# -ne 3 ]; then
echo "Usage:"
echo ""
echo " `basename $0` <unix socket file> <host> <listen port>"
echo ""
echo "For example:"
@davidoram
davidoram / schemaspy.sh
Last active May 31, 2018 01:44
Run dockerised schemaspy against a postgres database
#!/bin/bash
#
# - Run dockerised schemaspy against a postgres db
# - write the output to a host directory
# - Opens the generated website in your broswer
#
# Assumes you have already got the schemaspy docker image eg: `docker pull schemaspy/schemaspy:snapshot`
#
set -e
@davidoram
davidoram / github_get_all.sh
Last active November 11, 2018 23:50
Clone all github repositories for en organisation (git clone or git fetch --all)
#/bin/bash
#
# Checkout all repos, or brings branches up to date for an Org
#
read -d '' helptxt <<- "HELP_MSG"
Checkout all repos for a github organisation \\n
\\n
Usage:\\n
\\n
#/bin/bash
#
# Assumes you have run 'github_get_all.sh' to get the latest git repos for your org
#
# Note:This script will ONLY work reliably if you have run 'github_get_all.sh on an empty
# directory, so that all repos are freashly cloned and clean
#
# Iterate over all the github repos under the cwd, for each reports if
# branch1 is behind branch2
#
@davidoram
davidoram / server.go
Created March 3, 2022 02:33
Go server with ngrok
package main
//
// Run the server
// go run server.go
//
// Expose via ngrok
// ngrok http 8080
//
//