Skip to content

Instantly share code, notes, and snippets.

View bronzehedwick's full-sized avatar
🐌
digging in

Chris DeLuca bronzehedwick

🐌
digging in
View GitHub Profile
@bronzehedwick
bronzehedwick / gist:3984550
Created October 31, 2012 02:57
Edit gitignore alias
# Simple shortcut to edit your gitignore
# from anywhere inside your git repository
# Note that this will only work for gitignores
# in the top level directory
# To use, copy and paste the code
# into your bashrc or zshrc
alias egi="vim $(git rev-parse --show-toplevel)/.gitignore"
@bronzehedwick
bronzehedwick / prepare-commit-msg.sh
Created June 13, 2013 20:20
Git hook that inserts the current branch name in the commit title. Good for structures where the current branch = the ticket name. To install, rename this file to prepare-commit-msg and put it in .git/hooks.
#!/bin/sh
ORIG_MSG_FILE="$1"
TEMP=`mktemp /tmp/git-XXXXX`
TICKET=`git rev-parse --abbrev-ref HEAD`
(echo $TICKET": "; cat "$ORIG_MSG_FILE") > "$TEMP"
cat "$TEMP" > "$ORIG_MSG_FILE"
@bronzehedwick
bronzehedwick / GitHub status CLI
Last active December 20, 2015 21:19
Check github status from the command line
# GitHub provides a simple json api for it's status updates (status.github.com). jq is a very nice command line json parser http://stedolan.github.io/jq/.
# Combine the two, and you have a nifty GitHub status check, right from the command line!
# Add the following alias to your .bashrc or .zshrc; rename as you wish
ghs='curl https://status.github.com/api/last-message.json | jq .'
@bronzehedwick
bronzehedwick / new_post.sh
Last active December 12, 2022 13:05
Automate Jekyll Post Creation
#!/bin/bash
# Create a new post for a Jekyll blog.
cd /path/to/your/jekyll/repo/_posts
FILETILE=$(echo "$1" | tr " " "-" | tr '[:upper:]' '[:lower:]')
POSTDATE=$(\date +"%Y-%m-%d")
POSTNAME=$POSTDATE-$FILETILE.md
POSTBODY="---
layout: post
@bronzehedwick
bronzehedwick / hn.rb
Last active August 29, 2015 14:15
A ruby script to read hacker news from the terminal. I found this at http://andrewvos.com/2013/08/02/hacker-news-in-the-terminal/, but it didn't work for me, so these are my modifications. Please note, I have never programmed in ruby before.
#!/usr/bin/env ruby
require "httparty"
require "nokogiri"
require "rainbow"
require "ostruct"
require 'rainbow/ext/string'
def show_latest
response = HTTParty.get("http://news.ycombinator.com")
@bronzehedwick
bronzehedwick / gh_status.sh
Last active August 29, 2015 14:15
A little bash command line script to check Github's status with colored output!
#!/bin/bash
# Get status from Github
response=$(curl --silent https://status.github.com/api/last-message.json | sed "s/{//" | sed "s/}//")
IFS=',' read -a messages <<< "$response"
#Colors
red="\033[0;31m"
green="\033[0;32m"
yellow="\033[0;33m"
# Description
# A command to check Github's web status
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
@bronzehedwick
bronzehedwick / guess_number.html
Created June 9, 2015 13:44
Number guessing programming exorcise in Javascript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Guess My Number</title>
</head>
<body>
<script>
(function guessNumber() {
'use strict';
@bronzehedwick
bronzehedwick / add_commas.js
Last active February 14, 2018 14:26
Format a number with thousand's place seperating commas.
/**
* Format a number with thousand's place seperating commas.
* @param {number} num is the number to format.
* @returns {string} The formatted number.
*/
function addCommas( num ) {
var numString = num + '';
var numArray = numString.split('').reverse();
if ( numArray.length < 4 ) {
@bronzehedwick
bronzehedwick / random-es6.js
Last active April 29, 2016 13:56
Random whole number generator.
/**
* Returns a random number between min and max, rounded to the nearest whole number.
* @param {number} min is the lowest amount possible to return.
* @param {number} max is the highest amount possible to return.
* @returns {number} a random number between min and max.
*/
let random = (min, max) => Math.round(Math.random() * (max - min) + min);