Skip to content

Instantly share code, notes, and snippets.

View syl20bnr's full-sized avatar
🎹
♬♩♪·♫ ​​​​​​​​​​♬♩♪ ♪·♫ ♬♩

Sylvain Benner syl20bnr

🎹
♬♩♪·♫ ​​​​​​​​​​♬♩♪ ♪·♫ ♬♩
  • Tracel AI
  • Quebec City, Canada
  • 20:09 (UTC -04:00)
View GitHub Profile
@syl20bnr
syl20bnr / replaceinfileslinux
Created December 10, 2012 14:12
Replace in files (linux)
# replace in all xml files
find . -name "*.xml" | xargs sed -i 's/reg_exp/replace/g'
@syl20bnr
syl20bnr / nosudo
Created December 11, 2012 19:40
No sudo
Defaults:nova !requiretty
Cmnd_Alias NOVACMDS = /bin/aoe-stat, \
/bin/chmod, \
/bin/chmod /var/lib/nova/tmp/*/root/.ssh, \
/bin/chown, \
/bin/chown /var/lib/nova/tmp/*/root/.ssh, \
/bin/dd, \
/bin/kill, \
/bin/mkdir, \
/bin/mount, \
@syl20bnr
syl20bnr / robocop.bat
Created December 12, 2012 16:23
robocopy exit codes suck :-)
rem -------------------------------------------------------------------------------
rem this file controls the error level returned by the tool robocopy in order to
rem be usable in a custom build step of Visual Studio
rem -------------------------------------------------------------------------------
robocopy.exe /A-:R /NP /NJH /NJS /NDL /NFL /NS /NC %*
rem if errorlevel 16 echo Robocopy Exit Status: ***FATAL ERROR*** & exit /b 1
rem if errorlevel 15 echo Robocopy Exit Status: FAIL MISM XTRA COPY & exit /b 1
rem if errorlevel 14 echo Robocopy Exit Status: FAIL MISM XTRA & exit /b 1
@syl20bnr
syl20bnr / nodesktopsaveorsessionwarning.el
Created January 1, 2013 04:00
Remove annoying questions like “do you want to save desktop?” or “do you want to override last session file?”
;; Make emacs open all files in last emacs session.
;; Taken from ergoemacs, credits go to ergoemacs authors.
;; This functionality is provided by desktop-save-mode
;; (“feature” name: “desktop”).
;;
;; The mode is not on by default in emacs 23.1, and has a lot options.
;; The following is init settings for the mode for ErgoEmacs.
;; Goal: have emacs always auto open the set of opened files in last session,
;; even if emacs crashed in last session or the OS crashed in last session.
@syl20bnr
syl20bnr / emacsaliases.sh
Created January 1, 2013 04:39
zsh aliases for emacs. It starts the emacs daemon if required.
export EDITOR='emacsclient -t -n -a ""'
alias ec='emacsclient -c -n -a ""'
alias et='emacsclient -t -a ""'
ecs() { emacsclient -c -n -a emacs "/sudo::$*" }
ets() { emacsclient -t -a emacs "/sudo::$*" }
@syl20bnr
syl20bnr / evil-emacs-state-2-evil-normal-state.el
Last active April 29, 2020 10:00
evil-emacs-state is annoying, the following function and hook automatically switches back to evil-normal-state whenever the evil-emacs-state is entered. It allows a more consistent navigation experience among all mode maps. To enter special commands of custom mode maps, just enter the insert mode :-)
;; evil-emacs-state is annoying, the following function and hook automatically
;; switch back to evil-normal-state whenever the evil-emacs-state is entered.
;; It allows a more consistent navigation experience among all mode maps.
;; To enter special commands of custom mode maps, just enter the insert mode :-)
(defun evil-emacs-state-2-evil-normal-state ()
(evil-normal-state)
(remove-hook 'post-command-hook 'evil-emacs-state-2-evil-normal-state))
(add-hook 'evil-emacs-state-entry-hook
(lambda ()
(add-hook 'post-command-hook 'evil-emacs-state-2-evil-normal-state)))
@syl20bnr
syl20bnr / mu4e-msgv-action-open-message.el
Created January 5, 2013 07:11
Open the message at point in the default external browser.
;; adapted from https://groups.google.com/d/topic/mu-discuss/ZXB72TR5GL0/discussion
(defun mu4e-msgv-action-view-in-browser (msg)
"View the body of the message in a web browser."
(interactive)
(let ((html (mu4e-msg-field (mu4e-message-at-point t) :body-html))
(tmpfile (format "%s/%d.html" temporary-file-directory (random))))
(unless html (error "No html part for this message"))
(with-temp-file tmpfile
(insert
"<html>"
@syl20bnr
syl20bnr / evil-insert-line-no-state-change.el
Created April 18, 2013 21:05
This gist add functions to insert lines above and below the current line without changing the current evil state and current point position.
;; insert one or several line below without changing current evil state
(defun evil-insert-line-below (count)
"Insert one of several lines below the current point's line without changing
the current state and point position."
(interactive "p")
(save-excursion
(evil-save-state (evil-open-below count))))
;; insert one or several line above without changing current evil state
(defun evil-insert-line-above (count)
@syl20bnr
syl20bnr / ranger_autolaunch
Created April 26, 2013 15:01
Auto launch a ranger on top of every zsh session.
# Always launch a ranger session
if [[ $RANGER == "" ]]; then
export RANGER=1
ranger
fi
@syl20bnr
syl20bnr / init-popwin.el
Created May 4, 2013 03:44
popwin mode configuration working with helm.
(require 'popwin)
(setq display-buffer-function 'popwin:display-buffer)
(push '("^\*helm .+\*$" :regexp t) popwin:special-display-config)
(push '("^\*helm-.+\*$" :regexp t) popwin:special-display-config)