Skip to content

Instantly share code, notes, and snippets.

View Ketouem's full-sized avatar

Cyril Thomas Ketouem

View GitHub Profile
@Ketouem
Ketouem / updateToMaster.sh
Created January 18, 2016 10:02
Set bluntly a bunch of git repos contained in a folder up to date with the master branch
for file in */ ; do
if [[ -d "$file" && ! -L "$file" ]]; then
echo "$file is a directory, launching git commands.";
cd $file && git checkout master && git reset HEAD --hard && git pull --rebase --prune;
cd ..;
fi;
done
@Ketouem
Ketouem / renameGitBranch.sh
Created January 18, 2016 10:05
Rename a git branch both locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@Ketouem
Ketouem / simple_http_server_with_cors.py
Created January 18, 2016 10:06
Provides a (python 2) running instance of SimpleHTTPServer that can handle CORS
#! /usr/bin/env python2
from SimpleHTTPServer import SimpleHTTPRequestHandler
import BaseHTTPServer
class CORSRequestHandler (SimpleHTTPRequestHandler):
def end_headers (self):
self.send_header('Access-Control-Allow-Origin', '*')
SimpleHTTPRequestHandler.end_headers(self)
if __name__ == '__main__':
@Ketouem
Ketouem / dockerNuke.sh
Created January 18, 2016 10:08
Clean docker containers and images
# All images
docker rm `docker ps -aq`
docker rmi `docker images -q`
# Only <none>/<none>
docker rmi `docker images | grep '^<none>' | awk '{print $3}'`
@Ketouem
Ketouem / rebaseInitial.sh
Created January 18, 2016 10:09
Rebase from initial commit.
git rebase -i --root $tip
git commit --amend --author "Ketouem <ketouem@gmail.com>"
git rebase --continue
@Ketouem
Ketouem / changeCommitAuthor.sh
Created January 18, 2016 10:10
Change the author of a commit
git rebase -i -p <some HEAD before all of your bad commits>
git commit --amend --author "New Author Name <email@address.com>" --no-edit && \
git rebase --continue
@Ketouem
Ketouem / anacondaProject.json
Created January 18, 2016 10:13
SublimeText x Python configuration files
"settings":
{
"python_interpreter": "<path to python interpreter>",
"test_command": "<path to python interpreter> -m nose --nocapture"
}
@Ketouem
Ketouem / timestampCliOutput.sh
Created January 18, 2016 10:17
Adding a timestamp on each shell output line.
# OSX brew install moreutils
# Ubuntu apt-get install moreutils
<command> | ts '[%Y-%m-%d %H:%M:%S]'
@Ketouem
Ketouem / stKeyboardShortcuts.md
Created January 18, 2016 10:22
Useful SublimeText keyboard shortcuts
  • Ctrl(Cmd)+Shift+R: Search symbol in project
  • Ctrl(Cmd)+R: Search symbol in current file
  • Ctrl(Cmd)+P: Search file
  • Ctrl(Cmd)+Shift+P: Display list of commands
  • Ctrl(Cmd)+K, Ctrl(Cmd)+Shift+Up: Split Pane and sends to right pane
  • Ctrl(Cmd)+/: Toggle comment
  • Ctrl(Cmd)+Shift+Space: Select all in current scope
  • Ctrl+G: Go to line
  • Ctrl(Cmd)+F: Search in current file
  • Ctrl(Cmd)+Shift+F: Search & replace (in folders)
@Ketouem
Ketouem / sublimePackages.md
Last active January 18, 2016 10:31
SublimeText useful packages