Skip to content

Instantly share code, notes, and snippets.

@jrnewell
jrnewell / node-upgrade.sh
Last active August 29, 2015 14:03
BASH script to upgrade a local (user-level) node.js installation automatically
#!/usr/bin/env bash
# check arguments
if [ $# -ne 1 ]; then
echo "Usage: `basename $0` version" >&2
exit 1
fi
VERSION=$1
@jrnewell
jrnewell / init.d-template.sh
Created July 9, 2014 19:16
Template for init.d startup script that runs as a local user.
#! /bin/sh
### BEGIN INIT INFO
# Provides: SERVER-NAME
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the SERVER-NAME server
# Description: starts SERVER-NAME as a daemon
@jrnewell
jrnewell / py-ver.bat
Created July 20, 2014 22:01
Switch between Python2 and Python3 on MS Windows cmd
@echo off
goto START
-------------------------------------------------------
py-ver.bat
set the PYTHON_HOME to version 2 or 3
Created Sat May 11 13:00:00 2014
@jrnewell
jrnewell / go-path.cmd
Last active May 22, 2018 10:25
Set current directory to GOPATH on MS Windows cmd
@echo off
goto START
-------------------------------------------------------
go-path.bat
set the GOPATH to current directory
Created Sat May 3 20:00:00 2014
@jrnewell
jrnewell / bash.sh
Last active November 16, 2022 12:20
Bash functions
# list path env variable
function list-path() {
echo $PATH | tr ':' '\n'
}
# find text in files
function search() {
find . -type f -print0 | xargs -0 grep "$1"
}
[user]
name = James Newell
email = james.newell@gmail.com
[core]
excludesfile = /Users/james/.gitignore_global
editor = "subl -n -w"
[alias]
graph = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
lg = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
unpushed = log --branches --not --remotes --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
@jrnewell
jrnewell / console.xml
Created September 6, 2014 21:23
My Mac OS X Terminal Settings
<?xml version="1.0"?>
<settings>
<console change_refresh="10" refresh="100" rows="48" columns="200" buffer_rows="500" buffer_columns="0" shell="" init_dir="" start_hidden="0" save_size="0" background_text_opacity="255">
<colors>
<color id="0" r="0" g="0" b="0"/>
<color id="1" r="0" g="0" b="128"/>
<color id="2" r="0" g="150" b="0"/>
<color id="3" r="0" g="150" b="150"/>
<color id="4" r="170" g="25" b="25"/>
<color id="5" r="128" g="0" b="128"/>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BackgroundAlphaInactive</key>
<real>0.90362682481751821</real>
<key>BackgroundBlur</key>
<real>1</real>
<key>BackgroundBlurInactive</key>
<real>0.0</real>
@jrnewell
jrnewell / open.bash
Last active May 12, 2016 22:26
Open Sublime Text in Windows Cygwin
#!/bin/bash
run-fixed-cygpath "/cygdrive/c/Windows" explorer.exe "$@"
exit $?
@jrnewell
jrnewell / install-mingw-grep.sh
Last active October 12, 2016 12:07
A windows git-bash script to use a newer version of grep, egrep, fgrep in git-bash.
#!/bin/bash
set -e
set -o pipefail
cd $TEMP
archives=(
'grep-2.5.4-2-msys-1.0.13-bin.tar.lzma'
'libiconv-1.14-1-msys-1.0.17-dll-2.tar.lzma'