Skip to content

Instantly share code, notes, and snippets.

View tobiashm's full-sized avatar

Tobias H. Michaelsen tobiashm

View GitHub Profile
@tobiashm
tobiashm / profile.sh
Last active September 3, 2015 17:25
bash profile
if [ -d ~/.profile.d ]; then
for f in ~/.profile.d/*.sh; do source "$f"; done
unset f
fi
# -- RVM --
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
@tobiashm
tobiashm / fire_watir_ext.rb
Created September 16, 2009 09:00
useful extensions to FireWatir
# encoding: utf-8
require 'firewatir'
require 'iconv'
$KCODE = 'u'
# useful extension to FireWatir
class Element
# http://docs.jquery.com/Release:jQuery_1.3.2#:visible.2F:hidden_Overhauled
"G FMNC RM UGL UGRF LMRFGLE AMLACYJCB MP FCJB ZYAI DSJJ DPMLRYJ".split('').map(function(c) c == " " ? c : String.fromCharCode((c.charCodeAt() - 63) % 26 + 65)).join('');
@tobiashm
tobiashm / contrast-color.gemspec
Last active March 24, 2024 01:03
contrast-color for SASS
Gem::Specification.new do |spec|
spec.name = 'contrast-color'
spec.version = '0.1.1'
spec.platform = Gem::Platform::RUBY
spec.author = 'Tobias H. Michaelsen'
spec.email = '[email protected]'
spec.summary = 'Generate contrast colors in SASS'
spec.description = 'A simple extension to SASS that alows you to calculate colors that conforms to WAI and WCAG20 contrast requirements.'
spec.homepage = 'https://gist.github.com/243103'
spec.license = 'MIT'
@tobiashm
tobiashm / prototype-inheritance.js
Last active September 4, 2015 19:55
Example of prototype inheritance in JavaScript
// 'super' with prototype inheritance
function A() {}
A.prototype.say = function(m) { console.log('A: ' + m); };
function B() {}
B.prototype = new A();
B.prototype.say = function(m) {
this.constructor.prototype.say(m);
console.log('\nB: ' + m);
@tobiashm
tobiashm / fn-test.js
Created November 5, 2010 15:56
FunctionDeclarations vs FunctionExpression
try {
print(fn1);
print(fn2);
function fn1 () {} // FunctionDeclarations
(function fn2 () {}) // FunctionExpression
} catch (e) {
@tobiashm
tobiashm / extensions.cs
Created December 3, 2010 12:09
Extension methods for .NET
// Source: http://www.pluralsight-training.net/community/blogs/keith/archive/2010/11/12/min-max-between-limit.aspx
public static class IComparableExtensions
{
public static T Limit<T>(this T value, T minValue, T maxValue) where T : IComparable
{
if (value.CompareTo(minValue) < 0)
return minValue;
if (value.CompareTo(maxValue) > 0)
return maxValue;
return value;
@tobiashm
tobiashm / new-operator-test.js
Created December 16, 2010 12:47
JavaScript `new` operator return an object
function foo() { return 'foo'; }
function bar() { return foo; }
foo()
//=> "foo"
bar()
//=> function foo() { return 'foo'; }
new foo()
//=> [Object foo]
new bar()
//=> function foo() { return 'foo'; }
@tobiashm
tobiashm / ROD-Ex.patch
Created February 3, 2011 09:57
Modification of http://www.autohotkey.net/~Skan/Scripts/RoD/ROD-Ex.ahk to create 2 icons in resource.dll
24c24
< ResourceFile := "AutoHotkeySC.bin" ; you many comment out one of
---
> ;ResourceFile := "AutoHotkeySC.bin" ; you many comment out one of
71a72
> {
72a74,75
> GoSub,RT_ICON ; 2011-02-03/THM: Add another copy of the same icon to work around a bug in Stack Docklet 2.0
> }
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>`which node` "$TM_FILEPATH"</string>
<key>input</key>
<string>none</string>