Skip to content

Instantly share code, notes, and snippets.

View johntyree's full-sized avatar

iyknk johntyree

View GitHub Profile
@johntyree
johntyree / .vimrc
Created August 9, 2012 09:26
Remove trailing whitespace in Vim.
" Remove trailing whitespace
command! StripTrailingWhitespaces call <SID>StripTrailingWhitespaces()
nmap ,ws :StripTrailingWhitespaces<CR>
" Strip whitespace
function! <SID>StripTrailingWhitespaces()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
@johntyree
johntyree / rc.lua
Created August 7, 2012 13:45
Automagically save current session with rc.lua.
function window.init_funcs.auto_session_save (w)
w.tabs:add_signal("page-removed", function ()
if not session.closing then
w:save_session()
end
end)
session.closing = false
session.old_close_win = w.close_win
w.close_win = function (w, force)
session.closing = true
set_jquery_speed = function (view, w)
view:add_signal("load-status", function (v, status)
if status == "finished" and v.uri ~= "luakit://" then
v:eval_js([=[
if ($) {
$.fx.speeds._default = 70;
}
]=])
end
end)
" Vim syntax file
"
" Modification of vims Haskell syntax file:
" - match types using regular expression
" - highlight toplevel functions
" - use "syntax keyword" instead of "syntax match" where appropriate
" - functions and types in import and module declarations are matched
" - removed hs_highlight_more_types (just not needed anymore)
" - enable spell checking in comments and strings only
" - FFI highlighting
@johntyree
johntyree / pdf_split_by_bookmark.pl
Created February 3, 2012 14:09
Split PDF by bookmark (pdftk)
#!/usr/bin/env perl
use 5.013;
use warnings;
use Data::Dumper;
use File::Basename;
use File::Spec::Functions;
use File::Path qw(make_path);
my $pdftk = `/usr/bin/which pdftk`;
#!/usr/bin/env escript
-define(DELAY, 1000).
main(_Depth) ->
S = self(),
spawn(fun() -> keepGoing(50, S, 0) end),
spawn(fun() -> keepGoing(50, S, 0) end),
X = collectKids(),
io:format("\p\n", [X]),
-record(state, {server,
name="",
to_go=0}).
loop(S = #state{server=Server, to_go=[T|Next]}) ->
receive
{Server, Ref, cancel} ->
Server ! {Ref, ok}
after T*1000 ->
if Next =:= [] ->
Server ! {done, S#state.name};
Next =/= [] ->
loop(S#state{to_go=Next})
end
-module(kitchen).
-compile(export_all). %% Probably replace with -export([funcs])
-author("John Tyree").
fridge2(FoodList) ->
receive
{From, show} ->
From ! {self(), FoodList},
fridge2(FoodList);
{From, {store, Food}} ->
print('what?!')