Skip to content

Instantly share code, notes, and snippets.

Avatar
😀
writing status

Jonas Arnklint arnklint

😀
writing status
View GitHub Profile
@arnklint
arnklint / prepare-commit-msg
Created Oct 16, 2015 — forked from aalin/prepare-commit-msg
Git hook for adding issue numbers to commits
View prepare-commit-msg
#!/usr/bin/env ruby
filename = ARGV[0]
branch_name = `git rev-parse --abbrev-ref HEAD`
issue = branch_name[/^[A-Z]+-\d+/]
if issue
contents = File.read(filename)
File.write(filename, "#{ issue }:\n#{ contents }")
end
@arnklint
arnklint / ga-ratio.js
Created Feb 26, 2013 — forked from andrewrocco/ga-ratio.js
Track pixel ratio (*retina* or not) with Google Analytics in an easy way.
View ga-ratio.js
// Create the test
var pixelRatio = (window.devicePixelRatio >= 1.5) ? "high" : "normal";
..
// Pass it along through GA
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxx-x']);
// --- IMPORTANT LINE!
// params: event method, custom variable slot, variable name, variable value, scope level
@arnklint
arnklint / express-app.coffee
Created Dec 4, 2012 — forked from dangerbell/express-app.coffee
Example code for Node Testing with Mocha, SuperTest, and Nock
View express-app.coffee
express = require 'express'
app = express();
# Configure
require('./config')(app)
# Routes
require('./routes')(app)
module.exports = app
@arnklint
arnklint / madeofcode.vim
Created Jan 29, 2012 — forked from joshmvandercom/madeofcode.vim
Port of Made of Code Theme to VIM
View madeofcode.vim
" Port of my favorite theme Made of Code by Mark Dodwell
" For Textmate Theme visit - http://madeofcode.com/posts/29-photo-my-new-textmate-theme-8220-made-of-code-8221-mdash-download-9-feb-2010-update-t
" Vim color file
set background=dark
highlight clear
if exists("syntax_on")
syntax reset
@arnklint
arnklint / deploy.rb
Created Dec 30, 2011 — forked from mrrooijen/deploy.rb
Capistrano with Foreman Capfile
View deploy.rb
# encoding: utf-8
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require 'rvm/capistrano'
set :application, "hirefireapp"
set :repository, "git@codeplane.com:meskyanichi/myapp.git"
set :branch, "develop"
set :rvm_ruby_string, "1.9.2"
@arnklint
arnklint / person_test.rb
Created Sep 13, 2011 — forked from tenderlove/person_test.rb
Use minitest/spec with Rails 3
View person_test.rb
require 'test_helper'
require 'minitest/autorun'
class MiniTest::Spec
include ActiveSupport::Testing::SetupAndTeardown
include ActiveRecord::TestFixtures
alias :method_name :__name__ if defined? :__name__
self.fixture_path = File.join(Rails.root, 'test', 'fixtures')
end
@arnklint
arnklint / exception_mailer.rb
Created Aug 4, 2011 — forked from TomV/exception_mailer.rb
Simple Sinatra extension to catch exceptions and do some notifiyin (not working yet.)
View exception_mailer.rb
require 'sinatra/base'
module Sinatra
# module to catch Sinatra errors and send a email
module ExceptionMailer
def initialize(app)
@app = app
# set parameters here..
yield self if block_given?
end
@arnklint
arnklint / gist:1122573
Created Aug 3, 2011 — forked from ches/gist:718234
Very simple taggable behavior for Mongoid
View gist:1122573
# Basic tagging system for mongoid documents.
# jpemberthy 2010
#
# class User
# include Mongoid::Document
# include Mongoid::Document::Taggable
# end
#
# @user = User.new(:name => "Bobby")
# @user.tag_list = "awesome, slick, hefty"
@arnklint
arnklint / authentication.rb
Created May 24, 2011 — forked from jnunemaker/authentication.rb
a starting point for authentication with mongomapper and rails
View authentication.rb
# include this in application controller
module Authentication
protected
# Inclusion hook to make #current_user and #signed_in?
# available as ActionView helper methods.
def self.included(base)
base.send :helper_method, :current_user, :signed_in?, :authorized? if base.respond_to? :helper_method
end
# Returns true or false if the user is signed in.
@arnklint
arnklint / watchr.rb
Created May 23, 2011 — forked from ccollins/watchr.rb
watchr - cucumber, rspec
View watchr.rb
require 'growl'
require 'open3'
ENV["WATCHR"] = "1"
$spec_cmd = "env RSPEC_COLOR=true spec --drb --colour --format nested"
$cuke_cmd = "cucumber --color --drb --require features/step_definitions --require features/support"
$pass = File.join(File.expand_path(File.dirname(__FILE__)), '.watchr_images', 'pass.png')
$fail = File.join(File.expand_path(File.dirname(__FILE__)), '.watchr_images', 'fail.png')
$pending = File.join(File.expand_path(File.dirname(__FILE__)), '.watchr_images', 'pending.png')