This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| """ | |
| This is a command-line batch file-renaming utility. | |
| It uses regular expressions to transform filenames. | |
| This is especially helpful on Mac since Mac OS X does not include the Linux 'rename' command. | |
| Run with no arguments for help info. | |
| Author: Simon Radford (simonradf@gmail.com) | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # -------------------------------------------------- | |
| # This script grants READ AND WRITE permissions to staff, for the specified directory. | |
| # Takes 1 parameter ($1): A directory. | |
| # Recursively changes the directory to have group=staff, | |
| # and adds read and write permissions for that group. | |
| # Also adds execute permissions for all directories (but not files). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Set up custom bash command prompt. | |
| # Default is "\h:\W \u\$ ". | |
| RED="\[\e[0;31m\]" | |
| GREEN="\[\e[0;32m\]" | |
| BLUE="\[\e[0;34m\]" | |
| PLAIN="\[\e[m\]" | |
| PS1="${RED}\u@\h: \w\$ ${PLAIN}" | |
| # Aliases. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| """ | |
| This script monitors a set of processes, (re)starting them if they are not already running. | |
| This script is meant to be called periodically as a cron job. | |
| Example crontab entry: | |
| * * * * * $HOME/bin/python $HOME/misc/monit_cron.py 1>>$HOME/logs/cron/monit/monit_out.log 2>>$HOME/logs/cron/monit/monit_err.log | |
| 0 * * * * mv $HOME/logs/cron/monit/monit_out.log $HOME/logs/cron/monit/monit_out.log.1 | |
| 0 * * * * mv $HOME/logs/cron/monit/monit_err.log $HOME/logs/cron/monit/monit_err.log.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import logging | |
| import os | |
| import sys | |
| import time | |
| LOG_FORMAT = '%(asctime)s %(levelname)-8s %(message)s' | |
| DATE_FORMAT = '%m/%d %H:%M:%S %Z' | |
| # -------------------------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| iTerm2 Key Bindings | |
| =================== | |
| Fast way | |
| -------- | |
| 1. Run this command: | |
| echo '{"Touch Bar Items":[],"Key Mappings":{"0xf700-0x260000":{"Action":10,"Text":"[1;6A"},"0x37-0x40000":{"Action":11,"Text":"0x1f"},"0x32-0x40000":{"Action":11,"Text":"0x00"},"0xf709-0x20000":{"Action":10,"Text":"[17;2~"},"0xf70c-0x20000":{"Action":10,"Text":"[20;2~"},"0xf729-0x20000":{"Action":10,"Text":"[1;2H"},"0xf72b-0x40000":{"Action":10,"Text":"[1;5F"},"0xf705-0x20000":{"Action":10,"Text":"[1;2Q"},"0xf703-0x260000":{"Action":10,"Text":"[1;6C"},"0xf700-0x220000":{"Action":10,"Text":"[1;2A"},"0xf701-0x280000":{"Action":11,"Text":"0x1b 0x1b 0x5b 0x42"},"0x6c-0x100000":{"Text":"[C","Action":10},"0x38-0x40000":{"Action":11,"Text":"0x7f"},"0x33-0x40000":{"Action":11,"Text":"0x1b"},"0xf703-0x220000":{"Action":10,"Text":"[1;2C"},"0xf701-0x240000":{"Action":10,"Text":"[1;5B"},"0x4c-0x160000":{"Text":"","Action":34},"0xf70d-0x20000":{"Action":10,"Text":"[21;2~"},"0xf702-0x260000":{"Action":10,"Text":"[1;6D"},"0xf729-0x40000":{" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/env python | |
| """ | |
| A webserver to scramble a Rubik's cube. | |
| It renders a sequence of moves which you should perform to scramble your cube. | |
| The generated scrambles are perfectly, uniformly random. | |
| """ | |
| import sys | |
| import logging |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| git config --global user.name "Simon Radford" | |
| git config --global user.email "simonradf@gmail.com" | |
| git config --global color.ui true | |
| git config --global merge.conflictstyle diff3 | |
| git config --global diff.renames true | |
| git config --global push.default simple | |
| git config --global alias.st status | |
| git config --global alias.co checkout |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """This script will periodically poll pagerduty for triggered incidents, and acknowledge them.""" | |
| import urllib2 | |
| import time | |
| import json | |
| import sys | |
| import getpass | |
| if __name__ == '__main__': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| This script is a framework for programmatically resolving merge conflicts in a text file. | |
| You should overwrite resolve_conflict() with your own logic. | |
| Assumes the conflicts were generated inline by git, with the diff3 conflictstyle. | |
| To enable the diff3 conflictstyle, run this command: | |
| git config --global merge.conflictstyle diff3 | |
| Backup your source file before running with "overwrite" mode enabled. |
OlderNewer