Skip to content

Instantly share code, notes, and snippets.

View bjensen's full-sized avatar

Brian Jensen bjensen

View GitHub Profile
@bjensen
bjensen / gist:3049038
Created July 4, 2012 19:14 — forked from timothyekl/gist:1217887
Cross-platform: recompile LaTeX documents using Ruby, Guard
# Tested with Ruby 1.9
# Needs gem "guard" (https://github.com/guard/guard)
# Needs gem "guard-shell" (https://github.com/guard/guard-shell)
# Uses process "growlnotify" (http://growl.info/extras.php)
# Uses process "pdflatex" from standard TeXLive distribution
guard 'shell' do
watch(%r{(.+)\.tex}) do |m|
`growlnotify -m #{m[0]} Recompiling`
`pdflatex -interaction=batchmode #{m[0]} >/dev/null`
@bjensen
bjensen / gist:2881337
Created June 6, 2012 11:20
Redis: Delete the head item of the queue based on arguments
while((["arrival_notification","workshop_change_notification", "alert_navision_error"].include?(Resque.peek("mailer")["args"][0].to_s)) && (Resque.peek("mailer")["args"][1].to_s == "12")); Resque.pop("mailer"); puts "pop!"; end
@bjensen
bjensen / bootstrap_breadcrumbs_builder.rb
Created April 16, 2012 17:51
How to make breadcrumbs_on_rails render a Bootstrap compatible breadcrumb navigation
# The BootstrapBreadcrumbsBuilder is a Bootstrap compatible breadcrumb builder.
# It provides basic functionalities to render a breadcrumb navigation according to Bootstrap's conventions.
#
# BootstrapBreadcrumbsBuilder accepts a limited set of options:
# * separator: what should be displayed as a separator between elements
#
# You can use it with the :builder option on render_breadcrumbs:
# <%= render_breadcrumbs :builder => ::BootstrapBreadcrumbsBuilder, :separator => "&raquo;" %>
#
# Note: You may need to adjust the autoload_paths in your config/application.rb file for rails to load this class:
@bjensen
bjensen / hack.sh
Created March 31, 2012 11:09 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
:version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jul 22 2011 20:02:58)
MacOS X (unix) version
Included patches: 1-260
Compiled by Bjorn Winckler <bjorn.winckler@gmail.com>
Huge version with MacVim GUI. Features included (+) or not (-):
+arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent +clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments +conceal +cryptv +cscope +cursorbind
+cursorshape +dialog_con_gui +diff +digraphs +dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path +find_in_path +float +folding -footer +fork() +fullscreen -gettext
-hangul_input +iconv +insert_expand +jumplist +keymap +langmap +libcall +linebreak +lispindent +listcmds +localmap -lua +menu +mksession +modify_fname +mouse +mouseshape +mouse_dec -mouse_gpm
-mouse_jsbterm +mouse_netterm -mouse_sysmouse +mouse_xterm +multi_byte +multi_lang -mzscheme +netbeans_intg +odbeditor +path_extra +perl +persistent_undo +postscript +printer +profile +python -python3
@bjensen
bjensen / gist:981732
Created May 19, 2011 21:02
svg paths and arc
<svg xmlns="http://www.w3.org/2000/svg">
<!-- Middle point (M) of all out arcs. All arcs start at a point P <> M with
the distance d between P and M the radius of the arc. As the arcs are
to be circles , rx and ry will be equal d. The x-axis-rotation does
not have an effect on a circle, 0 is a good choice. -->
<circle cx="150" cy="150" r="5" fill="black" />
<!-- Arc path, given current point P (px, py) to new point N (nx, ny):
A rx ry
$ git clone github:lenary/guides.git
Cloning into guides...
remote: Counting objects: 255, done.
remote: Compressing objects: 100% (216/216), done.
remote: Total 255 (delta 111), reused 163 (delta 35)
Receiving objects: 100% (255/255), 1.49 MiB | 564 KiB/s, done.
Resolving deltas: 100% (111/111), done.
$ cd guides
$ git remote -v
namespace :db do
desc "This loads questions and categories for a specific workshop"
task :import_workshop_questionnaire => :environment do
puts "Workshopname: #{ENV['WORKSHOPNAME']}"
puts "File Path to CSV file #{ENV['CSVFILEPATH']}"
return if(ENV['WORKSHOPNAME'].blank? or ENV['CSVFILEPATH'].blank?)
class CSVParser
def initialize(workshopname, filepath)
#Keeps a list of registered names associated with classes at a "base" class
#Example:
#
# class Base
# extend Registerable
# end
#
# class Foo < Base
# register :foo
# end
# If your workers are inactive for a long period of time, they'll lose
# their MySQL connection.
#
# This hack ensures we re-connect whenever a connection is
# lost. Because, really. why not?
#
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar)
#
# From:
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/