Skip to content

Instantly share code, notes, and snippets.

View pre-commit
#!/usr/bin/env ruby
# This pre-commit hook will prevent any commit to forbidden branches
# (by default, "staging" and "production").
# Put this file in your local repo, in the .git/hooks folder
# and make sure it is executable.
# The name of the file *must* be "pre-commit" for Git to pick it up.
FORBIDDEN_BRANCHES = ["staging", "production"]
jamesdh /
Last active December 12, 2015 01:38
Extracts most known compression formats
# Extract most known archives
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar e $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
View launchd file for SelfControl
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
jamesdh /
Created May 31, 2016 19:32 — forked from lukaszb/
Simple Python script to send notification to the OSX Notifications Center (requires OS X 10.8+). Tested with pyobjc 2.5.1
#!/usr/bin/env python
from Foundation import NSUserNotification
from Foundation import NSUserNotificationCenter
from Foundation import NSUserNotificationDefaultSoundName
from optparse import OptionParser
def main():
parser = OptionParser(usage='%prog -t TITLE -m MESSAGE')
View AppleScript for SelfControl
on run argv
# fill in your working hours here
set start_time_morning to convert_minutes(8.0)
set finish_time_morning to convert_minutes(12.3)
set start_time_afternoon to convert_minutes(14.0)
set finish_time_afternoon to convert_minutes(18.0)
# -----------------------------------------
set start_time_morning_secs to start_time_morning * 3600
set finish_time_morning_secs to finish_time_morning * 3600
set start_time_afternoon_secs to start_time_afternoon * 3600
jamesdh / Commands For Compress And Decompressesing
Created October 18, 2018 15:00 — forked from zetavg/Commands For Compress And Decompressesing
bash commands for compress and decompressesing
View Commands For Compress And Decompressesing
# Usage:
# mk* OutputFileName.* InputDirName
# do* InputFileName
# un* InputFileName.*
# tar
alias mktar='tar cvf'
alias untar='tar xvf'
# gz
jamesdh / IntegrationSpec.groovy
Created March 2, 2021 14:43
Starting TestContainers and modifying config at startup in a Micronaut project
View IntegrationSpec.groovy
package com.example
import groovy.util.logging.Slf4j
import org.testcontainers.containers.GenericContainer
import org.testcontainers.utility.DockerImageName
import spock.lang.Specification
jamesdh / nginx.conf
Created April 6, 2021 20:46 — forked from micho/nginx.conf
nginx config for http/https proxy to localhost:3000
View nginx.conf
First, install nginx for mac with "brew install nginx".
Then follow homebrew's instructions to know where the config file is.
1. To use https you will need a self-signed certificate:
2. Copy it somewhere (use full path in the example below for server.* files)
3. sudo nginx -s reload
4. Access https://localhost/
Edit /usr/local/etc/nginx/nginx.conf:
jamesdh / justices.csv
Created June 2, 2021 20:31
Supreme Court Justices Data
View justices.csv
We can't make this file beautiful and searchable because it's too large.
jamesdh /
Created August 27, 2021 04:32 — forked from jahe/
JPA Cheatsheet
JPA (Java Persistence API)
Transaction Management with an Entity-Mananger: