Skip to content

Instantly share code, notes, and snippets.

@lionicsheriff
lionicsheriff / flag-branches.el
Last active December 16, 2015 21:21
Log the path a program through branches. Currently perl only
(defun warn-unique ()
"Inserts a warn statement with an incrementing buffer local id"
(interactive nil)
(if (not (boundp 'warn-unique-count))
(set (make-local-variable 'warn-unique-count) 0)
(set 'warn-unique-count (+ 1 warn-unique-count)))
(end-of-line)
(newline-and-indent)
(insert (concat "warn '**** " (number-to-string warn-unique-count) "';")))
@lionicsheriff
lionicsheriff / wc.rb
Last active December 18, 2015 06:08
Store word counts of files over a period
#!/usr/bin/env ruby
require 'sqlite3'
require 'date'
require 'optparse'
require 'iconv' unless String.method_defined?(:encode) # needed to fix dodgy encoding in files (String#encode is Ruby 1.9+)
CONFIG = {
:db_name => 'wc.db',
:base => '.',
:ignore_regexp => /^\s*(#|\*)/,
@lionicsheriff
lionicsheriff / devenv-compile.el
Last active October 7, 2016 16:19
Emacs: Compile visual studio projects from within emacs (M-x compile)
(defun mbg/devenv-compile nil
"Set up compile command for Visual Studio"
(interactive)
(let ((vsvars (shell-quote-argument "C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\Common7\\Tools\\vsvars32.bat"))
(solution-file (shell-quote-argument
;; awesomely, locate-dominating-file returns the directory for the file
;; so when you use a pattern to find a file, you need to run it again in
;; the directory itself to get the file name. Who knew.
(car (directory-files
(locate-dominating-file default-directory
@lionicsheriff
lionicsheriff / backup.sh
Last active January 1, 2016 22:59
Backup kindle books (from the kindle itself). For use in cron.
#!/bin/sh
SSID="YOUR WIRELESS SSID"
REMOTE_LOCATION="rsync://SERVER/module"
# wake up. Not sure if this is neccessary
# will error if already awake
lipc-set-prop com.lab126.powerd wakeUp 1
# start wireless
@lionicsheriff
lionicsheriff / version.tt
Last active August 29, 2015 14:03
The start of a t4 template to automatically update the version (based off the TFS revision). It was supposed to be able to work out of the box without any dependencies past VS Professional, but it is currently unable to update on build.
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Diagnostics" #>
<# #if false
* WTF
@lionicsheriff
lionicsheriff / chorded_keyboard.ino
Created August 19, 2014 15:19
The start of a chorded keyboard for the arduino.
// set up flags for the buttons
#define b1 B0000001
#define b2 B0000010
#define b3 B0000100
#define b4 B0001000
#define b5 B0010000
#define b6 B0100000
#define b7 B1000000
// make pin numbers easier to notice
;(use-package noflet :ensure t)
(provide 'auto-recover-mode)
(define-minor-mode auto-recover-mode
"more documentation"
:global t
(if auto-recover-mode
(progn
(advice-add 'after-find-file :around #'auto-recover-mode/after-find-file-no-warn)
(advice-add 'recover-this-file :around #'auto-recover-mode/always-yes)