Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
#
# Usage: git semver-tags [-p|--pre]
#
# Lists semver tags in the repository in order from newest to oldest.
#
# Useful for e.g. programmatically finding the latest release tag:
# `git semver-tags | head -n 1`.
#
# Tag names must be valid according to the SemVer 1.0.0 specification
@jakeasmith
jakeasmith / BaseAction.php
Created August 22, 2014 19:08
Terminating a session early
<?php
class BaseAction
{
protected $close_session = true;
public function __construct()
{
session_start();
if($this->close_session)) {
<?php
abstract class BaseType
{
abstract public function calculate($foo, $bar);
public function validate($baz)
{
return $baz === true;
}
@jakeasmith
jakeasmith / post-checkout
Created June 25, 2014 21:56
Git hooks for running composer when things change.
#!/bin/bash
# Put this file at: .git/hooks/post-checkout
# and make it executable
# You can install it system wide too, see http://stackoverflow.com/a/2293578/685587
# Original source: http://nschoenmaker.nl/2013/07/composer-post-checkout-hook-in-git/
PREV_COMMIT=$1
POST_COMMIT=$2

Keybase proof

I hereby claim:

  • I am jakeasmith on github.
  • I am jakeasmith (https://keybase.io/jakeasmith) on keybase.
  • I have a public key whose fingerprint is 857E 1166 E3F8 2B03 D031 EC7D 30D8 B376 3748 E328

To claim this, I am signing this object:

@jakeasmith
jakeasmith / .bash_aliases
Last active December 24, 2015 17:09
I used to have a bash profile somewhere with a lot of goodies in it, but it got lost in the shuffle between jobs this year. Feel free to copy, fork and do whatever you want with it. All I ask is that if you do something cool let me know so I can use it too!
# Colors
DARK_PURPLE="\[\033[1;34m\]"
GREEN="\[\033[0;32m\]"
GREY="\[\033[1;30m\]"
NORMAL="\[\033[0m\]"
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
# Git shortcuts
alias gci='git commit'
@jakeasmith
jakeasmith / mysqldump.sh
Last active June 28, 2021 20:07
A quick snippet for doing a compressed mysql dump with a pv to monitor progress
mysqldump [database] | pv | gzip -c > [file].sql.gz
@jakeasmith
jakeasmith / system-check.sh
Created May 9, 2013 20:28
A quick little script for verifying Git, VirtualBox and Vagrant are installed.
#!/bin/bash
command -v git >/dev/null 2>&1 && echo "Git is installed" || { echo >&2 "I require git but it's not installed. Please download it from http://git-scm.com/"; exit 1; }
command -v VBoxManage >/dev/null 2>&1 && echo "VirtualBox is installed" || { echo >&2 "I require VBoxManage but it's not installed. Please download it from https://www.virtualbox.org/"; exit 1; }
command -v vagrant >/dev/null 2>&1 && echo "Vagrant is installed" || { echo >&2 "I require vagrant but it's not installed. Please download it from http://www.vagrantup.com/"; exit 1; }
@jakeasmith
jakeasmith / terminal_debug.php
Created April 22, 2013 15:26
Just something I threw together this morning while parsing a CSV
<?php
/**
* Spits debug output to the terminal
*
* @return void
* @author Jake A. Smith
* @param string $msg the string to display
* @param int $line_breaks number of line breaks
* @param $bool $before Determines whether the line breaks will show before or after the message
@jakeasmith
jakeasmith / last_quarter_timestamp.php
Last active December 20, 2018 13:59
Get the timestamp for the beginning of the last quarter.
<?php
$start_date = strtotime('3 months ago');
$start_quarter = ceil(date('m', $start_date) / 3);
$start_month = ($start_quarter * 3) - 2;
$start_year = date('Y', $start_date);
$start_timestamp = mktime(0, 0, 0, $start_month, 1, $start_year);
echo $start_timestamp;