Skip to content

Instantly share code, notes, and snippets.

View linktohack's full-sized avatar

Quang-Linh LE linktohack

View GitHub Profile
@linktohack
linktohack / fortran-ampersand.el
Last active August 29, 2015 14:15
fortran insert continuation symbol (ampersand &) that match both fixed and free format.
(defun fortran-insert-f90-continuation ()
"Insert continuation symbol (ampersand &) that match both fixed and
free format.
If the inserted ampersand is the first non-blank character, just
insert it, otherwise, insert it at column 72 (zero-based index)
and insert another ampersand at column 6 on next line.
Also indent next line if `electric-indent-mode` is on."
(interactive)
@linktohack
linktohack / zshrc
Last active August 29, 2015 14:16
tor and socks proxy alias for OS X
function t () {
INTERFACE=Wi-Fi
sudo networksetup -setsocksfirewallproxy $INTERFACE 127.0.0.1 9050 off
sudo networksetup -setsocksfirewallproxystate $INTERFACE on
if ! [ -z $1 ]; then
mv /usr/local/etc/tor/torrc{,.t} 2>&1 > /dev/null
echo "ExitNodes {$1}" | tee /usr/local/etc/tor/torrc
fi
tor
if ! [ -z $1 ]; then
@linktohack
linktohack / PIV.F90
Last active August 29, 2015 14:17
fortran careful with implicit...
DO IPIV = 1, NPIV
WHERE (VALID(:,:,IPIV)==0)
UMOY = UMOY + U(:,:,IPIV)
VMOY = VMOY + V(:,:,IPIV)
UU = UU + U(:,:,IPIV)**2
VV = VV + V(:,:,IPIV)**2
UV = UV + U(:,:,IPIV)*V(:,:,IPIV)
NVALID = NVALID + 1
END WHERE
END DO
@linktohack
linktohack / dura.js
Last active August 29, 2015 14:17
filter link to download
console.log((function (match) {
a = document.querySelectorAll('a');
matched = [].filter.call(a, function (e) { return e.innerText.match(match); });
link = matched.map(function (e) { return window.location.href + e.getAttribute('href'); });
return link.join("\n");
})(/Horri/i));
@linktohack
linktohack / git.sh
Created March 30, 2015 08:09
git gc everything
git -c gc.reflogExpire=0 -c gc.reflogExpireUnreachable=0 -c gc.rerereresolved=0 -c gc.rerereunresolved=0 -c gc.pruneExpire=now gc
@linktohack
linktohack / lyxit
Last active October 20, 2015 13:57
vim/emacs edit current region in lyx
#!/bin/bash
TMPNAME=$(mktemp -t lyxit)
tee ${TMPNAME}.tex 2>/dev/null 1>/dev/null
tex2lyx ${TMPNAME}.tex 2>/dev/null 1>/dev/null
lyx ${TMPNAME}.lyx 2>/dev/null 1>/dev/null
lyx -e latex ${TMPNAME}.lyx 2>/dev/null 1>/dev/null
sed -e '1,/\begin{document}/d' -e '/\end{document}/,$d' ${TMPNAME}.tex \
| sed -e '/./,$!d' -e ':a' -e '/./,$!d;/^\n*$/{$d;N;};/\n$/ba'
@linktohack
linktohack / horri.js
Last active August 29, 2015 14:19
HorribleSubs all magnet links
[].filter.call(document.querySelectorAll('div.latest a'), function(e) {
return /^magnet/.test(e.getAttribute('href'));
}).filter(function(e) {
return /720p/.test(e.parentNode.parentNode.parentNode.innerText);
}).map(function (e) {
return e.getAttribute('href');
}).join('\n');
@linktohack
linktohack / .spacemacs.el
Created April 19, 2015 21:59
Emacs reset default theme
(mapc 'disable-theme custom-enabled-themes)
@linktohack
linktohack / *scratch*.el
Created April 20, 2015 17:20
emacs helper to open current file in Sublime Text and Lyx
(defun link/subl-file ()
"Edit current file in subl."
(interactive)
(shell-command (format "subl -n %s:%s"
(buffer-file-name)
(line-number-at-pos))))
(evil-define-operator link/subl-line (beg end type)
"Edit current region in subl."
:motion evil-line
(interactive "<R>")
@linktohack
linktohack / tangle.sh
Created April 28, 2015 14:23
Emacs tangle file command line
/opt/homebrew-cask/Caskroom/emacs-mac/emacs-24.5-z-mac-5.7/Emacs.app/Contents/MacOS/Emacs -Q --batch --eval "(progn (require 'org) (setq org-src-preserve-indentation t) (org-babel-tangle-file \"/Users/link/Dropbox/Researchs/Thesis/simple_thesis.org\"))"