Skip to content

Instantly share code, notes, and snippets.

View fd's full-sized avatar
🏳️‍🌈
Unstoppable

Simon Menke fd

🏳️‍🌈
Unstoppable
View GitHub Profile
@fd
fd / pq_with_schema_selector.go
Last active December 25, 2015 04:49
This is a wrapper for the `sql.Driver` in `github.com/lib/pq` which allows you to set the schema search path for each connection in the connection pool.
package postgres
import (
"database/sql"
"database/sql/driver"
"fmt"
"github.com/lib/pq"
"strings"
)
@fd
fd / gist:4731002
Last active December 12, 2015 06:39
Mr. Henry - Code Style document

Mr. Henry - Code Style document

=> YOU MUST FOLLOW THIS RULE.
=> YOU MUST NEVER, EVER DO THIS.

General

Variable names

✓ — Variable names should NEVER be acronims.

if Rails.env.staging?
FailtaleReporter.enabled = false
end
@fd
fd / glossary_regexp.rb
Created August 29, 2011 08:09
Glossary Regexp
description = file.description.clone
@glossary.each do |w|
terms = w.name.split(',')
terms.each do |term|
term = Regexp.escape(term.strip).gsub('\ ', '\s+')
description.gsub!(/(\b#{term}\b)/i, "<acronym rel=\"#{w.id}\">\\1</acronym>")
end
end
SCM_THEME_PROMPT_PREFIX=""
SCM_THEME_PROMPT_SUFFIX=""
RVM_THEME_PROMPT_PREFIX="["
RVM_THEME_PROMPT_SUFFIX="]"
SCM_THEME_PROMPT_DIRTY=' ${bold_red}✗${normal}'
SCM_THEME_PROMPT_CLEAN=' ${bold_green}✓${normal}'
SCM_GIT_CHAR='${bold_green}±${normal}'
SCM_SVN_CHAR='${bold_cyan}⑆${normal}'
@fd
fd / output.txt
Created May 24, 2011 13:56
yajl-ruby parser bug.
(in /Users/Simon/Projects/json_select/t)
FF
Failures:
1) Parser should not swallow the first object after parsing a number(integer)
Failure/Error: ]
expected: ["foo", "bar", 42, "baz", "bax"]
got: ["foo", "bar", 42, "bax"] (using ==)
Diff:
@fd
fd / not_super.rb
Created May 12, 2011 14:42
call a superclass method without `super`
class A
def foo
puts "bar #{self.class}"
end
end
class B < A
def foo
puts "baz #{self.class}"
end
/*
* Curry a JS function.
*
* Note:
* Curry doesn't change `this`.
*
* Example:
* function f(a, b, c){
* return [a, b, c];
* };
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script src="http://simonmenke.me/chains.js/build/jquery.stacks.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
(function(exports){
exports.state_machine = function(def){
@fd
fd / jquery.viewport.js
Created September 30, 2010 14:55
jQuery plugin for getting elements above, in or below the viewport
(function($){
$.fn.viewportState = (function(){
var results = [];
this.each(function(){
var bounds = this.getBoundingClientRect();
if (window.viewport.height() < bounds.top) {
results.push(['below', $(this)]);
} else if (bounds.bottom <= 0) {
results.push(['above', $(this)]);
} else {