Skip to content

Instantly share code, notes, and snippets.

View khalidchawtany's full-sized avatar

Khalid H. Ahmed khalidchawtany

View GitHub Profile
@khalidchawtany
khalidchawtany / pr.md
Last active August 29, 2015 14:16 — forked from piscisaureus/pr.md

Checkout a PullRequest

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git
@khalidchawtany
khalidchawtany / Git Stuff
Last active August 29, 2015 14:16
Git stuff that I forget all the time :)
#list branches
git branch #local branches
git branch -a #all branches
git branch -r #remote branches only
git branch -v #branches with latest commits
git branch -av #all branches with latest commits
#List branches by latest commit
git for-each-ref --sort=-committerdate refs/heads/

Colors in terminal

It's a common confusion about terminal colors... Actually we have this:

  • plain ascii
  • ansi escape codes (16 color codes with bold/italic and background)
  • 256 color palette (216 colors+16gray + ansi) (colors are 24bit)
  • 24bit true color (888 colors (aka 16 milion))
printf "\x1b[${bg};2;${red};${green};${blue}m\n"
#!/usr/bin/env bash
#
# Managing notes with fzf (https://github.com/junegunn/fzf)
# - CTRL-L: List txt files in descending order by their modified time
# - CTRL-F: Search file contents
NOTE_DIR="${NOTE_DIR:-$(dirname "${BASH_SOURCE[0]}")}"
TRASH_DIR="$NOTE_DIR/trash"
cd "$NOTE_DIR"
@khalidchawtany
khalidchawtany / b.rb
Last active August 29, 2015 14:22 — forked from junegunn/b.rb
#!/usr/bin/env bash
# vim: set filetype=ruby:
# b - browse Chrome bookmarks with fzf
[ $(uname) = Darwin ] || exit 1
which fzf > /dev/null 2>&1 || brew reinstall --HEAD fzf || exit 1
/usr/bin/ruby -x "$0" |
fzf-tmux -u 30% --ansi --multi --no-hscroll --tiebreak=begin |
awk 'BEGIN { FS = "\t" } { print $2 }' |
Process: Python [32823]
Path: /usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Identifier: Python
Version: 2.7.10 (2.7.10)
Code Type: X86-64 (Native)
Parent Process: nvim [32813]
Responsible: iTerm2 [4784]
User ID: 501
Date/Time: 2015-06-12 09:39:56.638 +0300
@khalidchawtany
khalidchawtany / tmux.md
Last active August 29, 2015 14:26 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@khalidchawtany
khalidchawtany / .phoenix.js
Created September 30, 2015 04:32
Pheonix config with modal keys
// This is my configuration for Phoenix <https://github.com/sdegutis/Phoenix>,
// a super-lightweight OS X window manager that can be configured and
// scripted through Javascript.
var mNone = [],
mCmd = ['cmd'],
mShift = ['shift'],
nudgePixels = 10,
padding = 0,
previousSizes = {};
Debugger entered--Lisp error: (file-error "Cannot open load file" "no such file or directory" "init")
signal(file-error ("Cannot open load file" "no such file or directory" "init"))
byte-code("\303\304 #\210\305!\210\306\n@\nA\"\207" [sym mode err message "Eval error in the `c-lang-defconst' for `%s' in %s:" makunbound signal] 4)
c-get-lang-constant(c-matchers-2 (cc-fonts) csharp-mode)
(defconst csharp-font-lock-keywords-2 (c-get-lang-constant (quote c-matchers-2) (quote (cc-fonts)) (quote csharp-mode)) ("/Volumes/Home/.emacs.d/elpa/csharp-mode-20150925.1354/csharp-mode.elc" . 18068))
csharp-mode()
set-auto-mode-0(csharp-mode nil)
set-auto-mode()
normal-mode(t)
after-find-file(nil t)
Debugger entered--Lisp error: (void-function eyebrowse-mode)
(eyebrowse-mode)
(progn (setq eyebrowse-new-workspace (function spacemacs/home) eyebrowse-wrap-around t) (eyebrowse-mode) (define-key evil-motion-state-map "gt" (quote eyebrowse-next-window-config)) (define-key evil-motion-state-map "gT" (quote eyebrowse-prev-window-config)) (defalias (quote spacemacs/workspaces-ms-rename) (function (lambda nil "Rename a workspace and get back to micro-state." (interactive) (eyebrowse-rename-window-config (eyebrowse--get (quote current-slot))) (spacemacs/workspaces-micro-state)))) (defalias (quote spacemacs//workspaces-ms-get-slot-name) (function (lambda (window-config) "Return the name for the given window-config" (let ((slot (car window-config)) (caption (eyebrowse-format-slot window-config))) (if (= slot current-slot) (format "[%s]" caption) caption))))) (defalias (quote spacemacs//workspaces-ms-get-window-configs) (function (lambda nil "Return the list of window configs. Depends on value of\n`eyebrowse-place