Skip to content

Instantly share code, notes, and snippets.

@volh
volh / prettier.el
Created April 25, 2018 08:28
Call prettier.js on current emacs buffer file
(defun shell-command-on-buffer (command)
"run a command on the current file and revert the buffer"
(interactive "sCommand:")
(shell-command
(format "%s %s"
command
(shell-quote-argument (buffer-file-name))))
(revert-buffer t t t))
(defun prettier-js-on-buffer ()
(defun daylight-mode ()
(interactive)
(mapc #'disable-theme custom-enabled-themes)
(setq fci-rule-color "lightgray")
(load-theme 'adwaita t)
(load-theme 'tango t))
(defun night-mode ()
(interactive)
(mapc #'disable-theme custom-enabled-themes)
@volh
volh / conkeror-org-protocol-capture.js
Last active August 29, 2015 14:22
Capture bookmarks from web browser right to your Org file with proper template
// Integration with Conkeror
// For Firefox, see https://addons.mozilla.org/ru/firefox/addon/org-mode-capture/
function org_capture (url, title, selection, window) {
// Note the 'w' as capture template
var cmd_str = 'emacsclient \"org-protocol://capture:/w/'+url+'/'+title+'/'+selection+'\"';
if (window != null) {
window.minibuffer.message('Issuing ' + cmd_str);
}
@volh
volh / gist:8826e0302bd52db8f792
Created May 7, 2015 14:54
emacs global dir-locals ( per-directory settings )
(dir-locals-set-class-variables 'smallindent-directory
'((nil . ((web-mode-markup-indent-offset . 2)
(web-mode-css-indent-offset . 2)
(web-mode-code-indent-offset . 2)
(js-indent-level . 2)
(whitespace-mode . -1)
(coffee-tab-width . 2)
(js2-basic-offset . 2)
))))
@volh
volh / gist:5760552
Created June 11, 2013 20:51
example of ssh config using LocalCommand option
PermitLocalCommand true
host localhost app* whatever_db* *exgirlfriendnameblog.net
user root
port 6666
LocalCommand echo -e "\033]11;#ff0000\007"
@volh
volh / gist:5433977
Last active December 16, 2015 12:19
play all the flash video/audio files open in chrome/firefox via mplayer
#!/bin/sh
mplayer $(find $(for i in `pgrep -f flashplayer`; do echo /proc/$i/fd/; done) -lname "*Flash*")
myLayout = ( (layoutN 1 (relBox 0 0 0.5 1) (Just $ relBox 0 0 1 1) $ simpleTabbed)
$ (layoutAll (relBox 0.5 0 1 1) $ simpleTabbed)
) |||
( (layoutN 1 (relBox (1/3) 0 (1/2) 1) (Just $ relBox 0 0 1 1) $ Tall 0 0.01 0.5)
$ (layoutR 0.1 0.5 (relBox (2/3) 0 1 1) Nothing $ Tall 0 0.01 0.5)
$ (layoutAll (relBox 0 0 (1/3) 1) $ Tall 0 0.01 0.5)
) |||
( (layoutN 1 (absBox (-512-200) 0 512 0) (Just $ relBox 0 0 1 1) $ simpleTabbed)
$ (layoutN 1 (absBox (-200) 0 0 0) Nothing $ simpleTabbed)
$ (layoutAll (absBox 0 0 (-512-200) 0) $ simpleTabbed)
@volh
volh / asound.conf
Created January 21, 2013 16:03
alsa config to play both through internal and external sound cards
pcm.!default plug:both
ctl.!default {
type hw
card 0
}
pcm.both {
type route;
slave.pcm {
function notification(title, body){
Components.classes['@mozilla.org/alerts-service;1'].
getService(Components.interfaces.nsIAlertsService).
showAlertNotification(null, title, body, false, '', null);
}
const OPEN_MASTER_WINDOW = 7;
function master_window () {
let windowMediator = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
let windows = windowMediator.getEnumerator(null);
let max_width = 0;
let master = null;
while (windows.hasMoreElements()) {
let win = windows.getNext()