Skip to content

Instantly share code, notes, and snippets.

View darrik's full-sized avatar

Rikard Glans darrik

  • Sweden
  • 04:06 (UTC +02:00)
View GitHub Profile
@darrik
darrik / reset-theme.el
Created June 14, 2012 00:23
darrik/reset-theme
(defun darrik/reset-theme ()
"Disable all loaded themes, effectively resetting to default colors."
(interactive)
(if (< emacs-major-version 24)
(message "Only works in Emacs 24+")
(progn
(mapcar 'disable-theme custom-enabled-themes)
(if (eq custom-enabled-themes nil)
(message "Theme reset.")))))
@darrik
darrik / revert-all-buffers.el
Created June 22, 2012 00:17
darrik/revert-all-buffers
;; Based on (org-revert-all-org-buffers)
(defun darrik/revert-all-buffers ()
(interactive)
(unless (yes-or-no-p "Revert all buffers?")
(error "Abort"))
(save-excursion
(save-window-excursion
(mapc
(lambda (buffer)
(when (with-current-buffer buffer buffer-file-name)
@darrik
darrik / darrikinsertdate.vim
Created June 22, 2012 00:23
Vim with MzScheme function example
" Extremely simple, just appends whatever you feed strftime to the end of the current line.
" If one was so inclined one could make it smarter like being able to insert at current cursor position and such.
function! DarrikInsertDate()
mz << EOF
(define (vim-strftime fmt)
(bytes->string/utf-8 (vim-eval (string-append "strftime('" fmt "')"))))
(define (vim-get-current-line-contents)
(bytes->string/utf-8 (vim-get-buff-line (car (vim-get-cursor)))))
@darrik
darrik / pdfxtheme.reg
Created June 30, 2012 22:31
Solarized dark "theme" for PDF-XChange Viewer
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Tracker Software\PDFViewer\PageDisplay\Colors\Overrides\Custom]
"TextFill"=dword:00969483
"LineArtFill"=dword:00423607
"UseLineArt"=dword:00000001
"UseText"=dword:00000001
"LineArtStroke"=dword:00756e58
"Background"=dword:00362b00
(defadvice newline-and-indent (after darrik-nai-curly-special activate)
"Do something special when RET between {}."
(when (eq (char-after) ?\})
(let ((pos (point)))
(if (search-backward "{")
(progn
(goto-char pos)
(newline)
(indent-according-to-mode)
(previous-line)
@darrik
darrik / .emacs
Created December 10, 2012 18:42
Lazy EPA/GPG file loading in Emacs
;; Populate epa-file-passphrase-alist
(load-file (concat (getenv "HOME") "/.secrets.el.gpg"))
@darrik
darrik / freebsd.txt
Created February 5, 2013 15:20
FreeBSD 9.0 to 9.1 upgrade issue
If you get stuck on the BTX boot loader spinner after doing the first step in upgrading from 9.0 to 9.1 you can try reinstalling the bootsector from a 9.1 cd (I used mfsbsd live usb image), that fixed it for me. I'm using GPT and zfs root so I issued "gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 <disk>" for all disks in my raidz root pool.
Standard disclaimer applies: use at your own risk, I take no responsibility for anything you might break.
@darrik
darrik / grtip.el
Created April 5, 2013 21:46
Don't resize windows that hold a *buffername* buffer.
(setq golden-ratio-inhibit-functions (lambda() (when (string-match "\*.*\*" (buffer-name)) t)))
@darrik
darrik / config
Created June 19, 2013 02:29
Rebar config for using mingw as compiler on windows ($HOME/.rebar/config)
%% -*- erlang -*-
{port_env, [{"win32", "CC", "gcc.exe"},
{"win32", "LINKER", "ld.exe"},
{"win32", "CFLAGS", "-O3 -march=native $ERL_CFLAGS"},
{"win32", "DRV_CFLAGS", "-g -Wall $ERL_CFLAGS"},
{"win32", "DRV_LDFLAGS", "-shared $ERL_LDFLAGS"},
{"win32", "DRV_CC_TEMPLATE", "$CC -c $CFLAGS $DRV_CFLAGS $PORT_IN_FILES -o $PORT_OUT_FILE"},
{"win32", "DRV_LINK_TEMPLATE", "$LINKER $PORT_IN_FILES $LDFLAGS $DRV_LDFLAGS -o $PORT_OUT_FILE"},
{"win32", "ERL_LDFLAGS", " -L$ERL_EI_LIBDIR -lerl_interface -lei"}
]}.
# Usage:
# [sudo] gem install mechanize
# ruby tumblr-photo-ripper.rb
require 'rubygems'
require 'mechanize'
# Your Tumblr subdomain, e.g. "jamiew" for "jamiew.tumblr.com"
site = "doctorwho"