Skip to content

Instantly share code, notes, and snippets.

View thejspr's full-sized avatar
🏋️

Jesper Kjeldgaard thejspr

🏋️
View GitHub Profile
@thejspr
thejspr / path-to-exif.rb
Created January 8, 2016 22:13
Set exif dates on images based on their filename
require 'time'
# Files with a name like "2010-12-08 12.34.20.png" gets their
# exif dates set to that time.
files = Dir.glob('*.*g')
files.each do |file|
date = file.to_s[0...file.to_s.length-4]
time = Time.parse(date.gsub('.', ':'))
@thejspr
thejspr / issue-branch
Last active October 14, 2015 04:56
Checkout branch named after title of a Github issue
#!/usr/bin/env ruby
require 'net/http'
require 'json'
token = ENV['GITHUB_TOKEN']
issue_id = ARGV.first
# get org and repo
repo_url = `git config --get remote.origin.url`.strip
@thejspr
thejspr / reloading.diff
Last active August 29, 2015 14:07
admin plugin
diff --git i/config/environment.rb w/config/environment.rb
index 7549e10..b1636d4 100644
--- i/config/environment.rb
+++ w/config/environment.rb
@@ -124,6 +124,7 @@ Rails::Initializer.run do |config|
config.autoload_paths << RAILS_ROOT + '/app/services'
config.plugin_paths << 'services'
+ config.reload_plugins = true if ENV["RAILS_ENV"] == 'development'
// ==UserScript==
// @name Travis--
// @namespace thejspr.com
// @version 0.1
// @description Removes some fuzz from the travis UI and improves it for large builds
// @match https://magnum.travis-ci.com/*
// @copyright 2014+, Jesper Kjeldgaard
// ==/UserScript==
$(document).ready(function(){
diff --git c/app/models/photo.rb w/app/models/photo.rb
index 60b3ab3..c6a99fb 100644
--- c/app/models/photo.rb
+++ w/app/models/photo.rb
@@ -51,6 +51,7 @@ class Photo < ActiveRecord::Base
:processors => [:thumbnail, :optimize],
:convert_options => {
:search_v4 => '-quality 70',
+ :banner => '-quality 80 -interlace Plane -strip'
}
@thejspr
thejspr / gist:5621122
Created May 21, 2013 16:21
Mute a given observer
def mute_observer(excluded_observer)
observers = ActiveRecord::Base.observers
ActiveRecord::Base.observers = observers - [excluded_observer]
yield
ensure
ActiveRecord::Base.observers = orig_observers
end
@thejspr
thejspr / gist:5576495
Created May 14, 2013 14:46
Add pivotal tracker story number to git commit messages.
#!/usr/bin/env ruby
# put this in .git/hooks/prepare-commit-msg
message_file = ARGV[0]
message = File.read(message_file)
pivotal_story_number = `git rev-parse --abbrev-ref HEAD | grep --only-matching '[0-9]*$'`.strip
# do not add anything if the branch doesn't have a story number or the message already contains one.
@thejspr
thejspr / gist:5030366
Created February 25, 2013 15:00
JSON vs. Msgpack benchmark
#!/usr/bin/env ruby
# JRuby
# gem install msgpack-jruby
# MRI
# gem install msgpack
require 'benchmark'
@thejspr
thejspr / prag_pub.rb
Created December 5, 2012 20:58
Download all PragPub issues from Pragmatic Programmers
#!/usr/bin/env ruby
# encoding: utf-8
require 'open-uri'
VALID_FORMATS = ['pdf', 'html', 'mobi', 'epub']
format = ARGV[0] || 'pdf'
unless VALID_FORMATS.include?(format)
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://evently-lister.herokuapp.com/evently-lister.js"></script>
<script>
$('#my-events').eventlyLister({
venue: '1' // for a venues events
promoter: '2' // for a promoters events
width: 3 // width of the widget (defaults to the containing elements' width)
theme: 'light' // select a theme (optional)
})
</script>