Skip to content

Instantly share code, notes, and snippets.

View linktohack's full-sized avatar

Quang-Linh LE linktohack

View GitHub Profile
;; Map CapsLock to LCtrl
;; LAtl to RCtrl
;; LCtrl to RAlt
;; using SharpKeys first
>^Tab::AltTab
>^q::Send, !{F4}
;; Not Emacs, not Console
#IfWinNotActive ahk_class Emacs
@linktohack
linktohack / .Xmodmap
Last active August 29, 2015 14:21
CapsLock as LCtrl, LCtrl as RAtl and LAlt as RCtrl
clear lock
clear control
clear mod1
clear mod4
! Caps_Lock
keycode 66 = Control_L
! Control_L
keycode 37 = Super_L
! Super_L
@linktohack
linktohack / subl.sh
Created May 28, 2015 14:36
subl for linuxmacs
#!/bin/sh
if [ $1 = "-" ]; then
shift
TEMP=$(mktemp)
cat > $TEMP
/opt/sublime_text/sublime_text -w $TEMP "$@"
cat $TEMP
rm -rf $TEMP
else
exec /opt/sublime_text/sublime_text "$@"
@linktohack
linktohack / waitFor.js
Created July 21, 2015 11:53
waitFor as a Promise
function waitFor(testFx, onReady, timeOutMillis) {
return new Promise(function (resolve, reject) {
var maxtimeOutMillis = timeOutMillis ? timeOutMillis : 3000,
start = new Date().getTime(),
condition = false,
interval = setInterval(function() {
if ((new Date().getTime() - start < maxtimeOutMillis) && !condition) {
condition = (typeof(testFx) === "string" ? eval(testFx) : testFx());
} else {
if(!condition) {
@linktohack
linktohack / promise.js
Last active August 29, 2015 14:25
Promise in 50 lines of code
var Promise = (function() {
var Promise = function(callback) {
this._done = [];
this._fail = [];
this.state = 'pending';
this.value = undefined;
callback && callback(this.resolve.bind(this), this.reject.bind(this));
};
Promise.prototype = {
resolve: function(value) {
@linktohack
linktohack / init.el
Created August 3, 2015 08:06
Helm in Popwin
(setq popwin:special-display-config
(append '(("^\*helm .+\*$" :regexp t :position right :width 60)
("^\*helm-.+\*$" :regexp t :position right :width 60))
popwin:special-display-config))
(add-hook 'helm-after-initialize-hook (lambda ()
(popwin:display-buffer helm-buffer t)
(popwin-mode -1)))
(add-hook 'helm-cleanup-hook (lambda () (popwin-mode 1)))
@linktohack
linktohack / lighttpd.conf
Created September 29, 2015 07:48
Lighttpd simple configuration
server.document-root = "/home/link/Downloads"
server.port = 3000
mimetype.assign = (
".html" => "text/html",
".txt" => "text/plain",
".jpg" => "image/jpeg",
".png" => "image/png"
)
@linktohack
linktohack / lastpass.sh
Created September 29, 2015 15:50
Another password manager
function lastpass () {
url=""
username=""
password=""
function fill() {
pb=$(pbpaste)
osascript -e 'tell application "System Events" to keystroke tab using command down'
echo "$username" | pbcopy
osascript -e 'tell application "System Events" to keystroke "v" using command down'
osascript -e 'tell application "System Events" to keystroke tab'
@linktohack
linktohack / zshrc.zsh
Last active August 23, 2023 14:44
ZSH
export EDITOR=vim
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="nicoulaj"
plugins=(asdf aws docker direnv fasd fzf git helm history jq kubectl macos)
source $ZSH/oh-my-zsh.sh
export FZF_DEFAULT_OPTS="--bind ctrl-k:kill-line,ctrl-b:preview-page-up,ctrl-f:preview-page-down"
export _FASD_BACKENDS="native spotlight"
export PATH="$PATH:$HOME/Library/Android/sdk/platform-tools"
@linktohack
linktohack / 6.el
Last active January 4, 2016 23:38
Regions - multiple selections
(provide 'regions)
(defvar regions nil
"Regions in buffer.")
(defun regions-maybe-push-selection ()
"Push mark and point if point is not in regions."
(let ((point (point))
exists)
(dolist (sel regions)