Skip to content

Instantly share code, notes, and snippets.

View remvee's full-sized avatar

Remco van 't Veer remvee

  • 52°N, 5°E
View GitHub Profile
(function($) {
$.fn.highlight = function(options) {
var $el = $("<div></div>"),
delay = (options && options["delay"]) || 0;
var container = $(this)[0];
if ($(this).parents("table").length) {
container = $(this).parents("table")[0];
}
@remvee
remvee / i18n.rb
Last active August 29, 2015 14:02
Rake tasks to find missing translations by comparing available yml files.
namespace :i18n do
task en_bork: :environment do
I18n.locale = :en
en = I18n.t(".").except(:faker)
chef = replace_values!(en) do |val|
`echo #{val.inspect} | chef`.chomp.sub(/\s*Bork Bork Bork!/m, "")
end
File.open(Rails.root + "config/locales/en-bork.yml", "w") do |fd|
#!/usr/bin/env ruby
require 'base64'
require 'tempfile'
min, max = ARGV.map{|v| v.to_i}
raise "#{__FILE__} MIN MAX" unless min && max && min > 0 && min < max
MESSAGES = ["rechtop zitten!", "schouders naar achteren!", "stapelen!", "water drinken!"]
@remvee
remvee / app.cljs
Last active August 29, 2015 14:13
Detect on screen keyboard
(defn detect-keyboard-on-screen!
"Try to detect keyboard going on and off screen and toggle class on
the element when applicable."
[el class]
(let [former-height (atom (.-innerHeight js/window))]
(.addEventListener
js/window "resize"
#(let [focus (.-activeElement js/document)
height (.-innerHeight js/window)]
(gclasses/enable el class
@remvee
remvee / image.cljs
Last active August 29, 2015 14:19
Draw image on a canvas with the given EXIF orientation
(defn draw-image [canvas img orientation]
(let [ctx (.getContext canvas "2d")
[width height] (.-width img) (.-height img)]
(case orientation
(1 nil) ; left top
(do
(set! (.-width canvas) width)
(set! (.-height canvas) height)
(.drawImage ctx img 0 0 width height))
@remvee
remvee / twit.el
Created September 24, 2008 07:36
Emacs interface for twitter.com
;;; Twit.el --- interface with twitter.com
;; Copyright (c) 2007 Theron Tlax
;; (c) 2008 Jonathan Arkell
;; Time-stamp: <2007-03-19 18:33:17 thorne>
;; Author: thorne <thorne@timbral.net>, jonnay <jonnay@jonnay.net>
;; Created: 2007.3.16
;; Keywords: comm
;; Favorite Poet: E. E. Cummings
@remvee
remvee / gist:24951
Created November 14, 2008 15:40
bookmarklet to fix line-height for current page
javascript:(function(){var%20d=document;t=d.createElement(%22style%22);t.appendChild(d.createTextNode(%22*{line-height:2}%22));d.getElementsByTagName(%22head%22)[0].appendChild(t)})();
@remvee
remvee / font-zoom.el
Created February 24, 2009 08:53
font-zoom.el
;; Font zooming with Hyper--/=/0 for Mac
;; Inspired by: http://www.emacswiki.org/cgi-bin/wiki/CycleFontSizes
(defconst font-zoom-list
(mapcar (lambda (n) (format "-*-monaco-*-*-*-*-%d-*-*-*-*-*-*-*" n)) '(6 8 10 13 17 18 24 36 48)))
(defconst default-font-zoom-index 3)
(defvar font-zoom-index default-font-zoom-index)
(defun font-zoom-increase-font-size ()
@remvee
remvee / gist:131946
Created June 18, 2009 15:12
thank god for tests
--- a/app/controllers/security.rb
+++ b/app/controllers/security.rb
@@ -10,7 +10,7 @@ module Security
# Ensure somebody is logged in. Takes the same options as
# +before_filter+.
def authenticate(options = {})
- before_filter options.dup { |controller| controller.send(:authenticate) }
+ before_filter(options.dup) { |controller| controller.send(:authenticate) }
end
@remvee
remvee / elf_proef.rb
Created November 19, 2009 11:32
validate dutch social security and bank numbers
# Methods to validate dutch social security numbers
# (burgerservicenummer) and back account numbers
# (bankrekeningnummers) using the "elf proef".
module ElfProef
def valid_burgerservicenummer?(val)
num = val.to_s.scan(/\d/).join.to_i
return false if num == 0
digits = ("%09d" % num).split(//).map(&:to_i).reverse
return false unless digits.size == 9