Skip to content

Instantly share code, notes, and snippets.

View AlexanderRD's full-sized avatar

Alexander Donkin AlexanderRD

View GitHub Profile
@AlexanderRD
AlexanderRD / gist:2402e390908a268bc877d8903bbcce1c
Created June 28, 2018 12:07
Export Grape API docs to single html file using Swagger and Bootprint
# Ensure swagger docs have been generated for your app,
# by weirdly running your app locally and navigating to route
# that matches whwere the docs are mounted
rails s -p 3001
# Install bootprint
npm install -g bootprint
npm install -g bootprint-openapi
# Use Bootprint to generate docs from the default swagger docs location
@AlexanderRD
AlexanderRD / Exclude release|master branches
Created November 30, 2017 11:36
Local dev gihub branch clean-up
#Only delete branches merged into their upstream origins
git branch | grep -v "master" | grep -v "release" | xargs -n 1 git branch -d
# Delete branch regardless of merge status
git branch | grep -v "master" | grep -v "release" | xargs -n 1 git branch -D
def bin_to_hex(s)
s.unpack('H*').first
end
def hex_to_bin(s)
s.scan(/../).map { |x| x.hex }.pack('c*')
end
#Kudos to: http://anthonylewis.com/2011/02/09/to-hex-and-back-with-ruby/
rubocop -a `git diff --name-only --cached | grep '\.rb'`
@AlexanderRD
AlexanderRD / command_line
Created November 13, 2015 07:03
OS X to restart MySQL server
sudo /usr/local/mysql/support-files/mysql.server restart
@AlexanderRD
AlexanderRD / gist:485f12395cc30f3444b7
Last active August 26, 2022 00:29
Delete all git branches with prefix
git branch -D `git branch | grep 'ard_*'`
@AlexanderRD
AlexanderRD / chosen_select.js
Created September 10, 2015 09:12
Rails chosen select example
$(function() {
$('.chosen-select').chosen({
allow_single_deselect: true,
no_results_text: 'No results matched'
});
});
@AlexanderRD
AlexanderRD / credential_adapter.rb
Created August 31, 2015 12:43
Credential adapter; wraps hash and converts keys into methods
module Patterns
class CredentialAdapter
attr_reader :config_params
def initialize(config_params ={})
@config_params = config_params
end
def method_missing(message, *args, &block)
if config_params.include?(message)
@AlexanderRD
AlexanderRD / gist:b8d94553edcdf9216af6
Created April 16, 2015 06:36
Basic FluidReview jQuery Styling
$( document ).ready(function() {
// Registration specific styling
$('#registration .logo').css({"text-align": "center","border-radius": "5px","background": "rgba(255,255,255,0.1)"});
$('#registration').css({"border-radius": "5px"});
// Login specific styling
$('#login').css({"background": "rgba(255,255,255,0.9)","border-top-width": "0"});
});
@AlexanderRD
AlexanderRD / gist:3266874f18b37c72529d
Created December 17, 2014 11:02
Basic mysqldump import/export examples
To export:
mysqldump -u mysql_user -p DATABASE_NAME > backup.sql
To import:
mysql -u mysql_user -p DATABASE < backup.sql