Skip to content

Instantly share code, notes, and snippets.

View rbramwell's full-sized avatar
🚀
Blazing a trail the likes of which has never been seen.

Rory Bramwell rbramwell

🚀
Blazing a trail the likes of which has never been seen.
View GitHub Profile
@jeremyjarrell
jeremyjarrell / Prefix migrations with timestamp Ant task
Last active May 15, 2017 15:53
An Ant task that prefixes new SQL migration files with a timestamp precise to milliseconds. The following usage will add a prefix to any SQL file in a hardcoded directory that does not begin with an number and double leading underscore: $ ant prefix-new-migrations
<project name="migrations">
<target name="prefix-new-migrations">
<foreach target="rename-file" param="the-file">
<path>
<!-- The hardcoded directory containing the migrations -->
<fileset dir="./src/db/migrations" casesensitive="no" includes="*.sql">
<!-- Exclude any migration files which have already been prefixed -->
<not>
<filename regex="\d+__.*" casesensitive="true"/>
@jeremyjarrell
jeremyjarrell / Prefix migrations with timestamp Groovy task
Created July 25, 2013 20:00
A Groovy task that prefixes new SQL migration files with a timestamp precise to milliseconds. The following usage will add a prefix to any SQL file in a hardcoded directory that does not begin with an number and double leading underscore: $ gradle prefixNewMigrations
task prefixNewMigrations {
fileTree(dir: 'dev/src/db/listhub').exclude({ isFilePrefixed(it.file) }).each { file ->
doLast {
def timestamp = new Date().format('yyyyMMddHHmmssSSS', TimeZone.getTimeZone('GMT'))
println "Renaming $file.name to ${timestamp}__$file.name"
file.renameTo("$file.parentFile.absolutePath$file.separator${timestamp}__$file.name")
@jeremyjarrell
jeremyjarrell / Idempotent migration in MySQL example
Created July 25, 2013 20:06
In MySQL, IF statements cannot exist outside of stored procedures. Therefore, to create an idempotent migration for MySQL it's necessary to wrap the migration in a stored procedure and execute that stored procedure against the database to perform the migration.
DELIMITER $$
DROP PROCEDURE IF EXISTS add_email_address_column_to_customers_table $$
-- Create the stored procedure to perform the migration
CREATE PROCEDURE add_email_address_column_to_customers_table()
BEGIN
-- Add the email_address column to the customers table, if it doesn't already exist
@terrywang
terrywang / Berkshelf
Last active October 25, 2019 23:20
Vagrantfile sample for Vagrant, the following plugins are required: vagrant-berkshelf, vagrant-omnibus, vagrant-proxyconf, vagrant-vbguest, vagrant-proxyconf. Berksfile defines cookbooks and their dependencies. Run berks install to install cookbooks and dependencies.
site :opscode
cookbook 'nginx', '~> 2.4.4'
@hrwgc
hrwgc / validate.sh
Created November 13, 2013 19:57
bash wget - check if file exists at url before downloading
#!/bin/bash
# simple function to check http response code before downloading a remote file
# example usage:
# if `validate_url $url >/dev/null`; then dosomething; else echo "does not exist"; fi
function validate_url(){
if [[ `wget -S --spider $1 2>&1 | grep 'HTTP/1.1 200 OK'` ]]; then echo "true"; fi
}
@jakemmarsh
jakemmarsh / binarySearchTree.py
Last active September 26, 2022 18:06
a simple implementation of a Binary Search Tree in Python
class Node:
def __init__(self, val):
self.val = val
self.leftChild = None
self.rightChild = None
def get(self):
return self.val
def set(self, val):
@jjongsma
jjongsma / packer-config
Last active December 18, 2023 15:15
Process YAML and write Packer JSON to STDOUT
#!/usr/bin/python
#
# Usage: packer-config my-template.yaml | packer build -
#
# Constructs a Packer JSON configuration file from the specified YAML
# template file and writes it to STDOUT.
#
# The YAML template format adds some flexibility and readability by
# adding comments and an !include directive, allowing for the
# following template syntax:
@Integralist
Integralist / GitHub curl.sh
Last active September 7, 2023 03:53 — forked from madrobby/gist:9476733
Download a single file from a private GitHub repo. You'll need an access token as described in this GitHub Help article: https://help.github.com/articles/creating-an-access-token-for-command-line-use
curl --header 'Authorization: token INSERTACCESSTOKENHERE' \
--header 'Accept: application/vnd.github.v3.raw' \
--remote-name \
--location https://api.github.com/repos/owner/repo/contents/path
# Example...
TOKEN="INSERTACCESSTOKENHERE"
OWNER="BBC-News"
REPO="responsive-news"
@chiraggude
chiraggude / Install Ruby and RubyGems
Last active December 14, 2018 07:14
Install Ruby 2.1.1 and RubyGems 1.8.25 on CentOS 6.5
# Install Ruby
wget http://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.1.tar.gz
tar xvzf ruby-2.1.1.tar.gz
cd ruby-2.1.1
./configure --prefix=/usr
make
make install
# remove "ruby-2.1.1" folder in /root
@sr75
sr75 / wget-jdk-oracle-install-example.txt
Last active March 16, 2023 11:28
wget command to install Oracle JAVA JDK from stupid oracle website for centos and ubuntu
http://d.stavrovski.net/blog/post/how-to-install-and-setup-oracle-java-jdk-in-centos-6
# rpm
wget --no-cookies \
--no-check-certificate \
--header "Cookie: oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/7u55-b13/jdk-7u55-linux-x64.rpm" \
-O jdk-7-linux-x64.rpm
# ubuntu