Skip to content

Instantly share code, notes, and snippets.

@brandhill
brandhill / gist:18845c14bc98e51bb713274c8bc14e2d
Created May 8, 2017 12:52
remove commit from remote branch
git reset HEAD^ # remove commit locally
git push origin +HEAD # force-push the new HEAD commit
git push origin +HEAD^:<name of your branch, most likely 'master'> # Ex: git push origin +HEAD^:Ring_master
@brandhill
brandhill / com.user.loginscript.plist
Last active May 31, 2017 02:03
Run a script at login for all users
<?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>Label</key>
<string>com.user.loginscript</string>
<key>ProgramArguments</key>
<array>
<string>/path/to/executable/script.sh</string>
</array>
@brandhill
brandhill / mount_ramdisk.sh
Created May 5, 2017 13:21
create/delete a ramdisk on mac
#!/bin/sh
# 只要執行 mount_ramdisk.sh 就會建立一個 4GB 的 RAM disk,
# 執行 mount_ramdisk.sh 2 就會建立一個 2GB 的 RAM disk,
# 執行 mount_ramdisk.sh -u 就可以卸載掉 RAM disk:
RAM_DISK_GB=4
RAM_DISK_NAME=RamDisk
MOUNTED_RAM_DISK_FOLDER="/Volumes/${RAM_DISK_NAME}"
# Unmount RAM disk

Videos

@brandhill
brandhill / git.migrate
Created March 16, 2017 03:55 — forked from niksumeiko/git.migrate
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@brandhill
brandhill / update-jenkins.sh
Created March 4, 2017 08:22
the script to update jenkins
#!/bin/bash
DEFAULT_URL=http://updates.jenkins-ci.org/current/latest/jenkins.war
TMP_PATH=/tmp/jenkins.war
APP_PATH=/Applications/Jenkins/jenkins.war
PLIST_PATH=/Library/LaunchDaemons/org.jenkins-ci.plist
url=${1-$DEFAULT_URL}
echo 'Downloading WAR package...'
{
"applinks": {
"apps": [],
"details": [
{
"appID": "9JA89QQLNQ.com.apple.wwdc",
"paths": [ "/wwdc/news/", "/videos/wwdc/2015/*"]
},
{
"appID": "ABCD1234.com.apple.wwdc",
{
"aps": {
"sound": "",
"content-available": 1
},
"custom_key": {
"custom_key_1": "custom_value_1",
"custom_key_2": "custom_value_2"
}
}