Skip to content

Instantly share code, notes, and snippets.

@polarblau
polarblau / gitfix.sh
Last active August 29, 2015 13:57
Amend a commit with same message by default.
function gfix {
DEFAULT_MESSAGE=$(git log -1 HEAD --pretty-format:%s)
MESSAGE=${1:-$DEFAULT_MESSAGE}
git commit --amend -m "$MESSAGE"
}
@polarblau
polarblau / media_and_ie.sass
Created March 26, 2014 09:34
Sass mixin to target media queries and IEs
// Depends on bourbon/neat for the +media mixin
// Swap for you own implementation as needed
=media-and-ie($query, $total-columns: $grid-columns, $ies: (7, 8))
$ie-selectors: ()
+media($query, $total-columns)
@content
@each $ie in $ies
$ie-selectors: append($ie-selectors, unquote('html.lt-ie#{$ie + 1} &'), comma)
#{$ie-selectors}
@polarblau
polarblau / gist:11264189
Created April 24, 2014 18:14
Shades of grey

By Inge Geerdens, originally published on LinkedIn (https://www.linkedin.com/today/post/article/20140423114614-44558-shades-of-grey)

The other day, I had to let go of an employee. Not because he was performing poorly, but simply because our business had changed completely over the past few years (I sold one company) and we didn't have any new projects fitting his profile nor preferences. It wasn't a decision I made overnight. It wasn't even my decision. We talked about it on several occasions. And eventually we agreed to terminate our collaboration as soon as he would have found a new challenge. It felt like the right thing to do after having worked together for so many years. And I was convinced he would find that new challenge soon enough. I was happy we would be able to go our separate ways in good order and hoped he would find a new position where his competencies would be more valued.

Fast forward. We're now just a few weeks later, outside office hours. I'm still on the job though, together with anothe

function _git_prompt() {
local git_status="`git status -unormal 2>&1`"
if ! [[ "$git_status" =~ Not\ a\ git\ repo ]]; then
if [[ "$git_status" =~ nothing\ to\ commit ]]; then
local ansi=42
elif [[ "$git_status" =~ nothing\ added\ to\ commit\ but\ untracked\ files\ present ]]; then
local ansi=43
else
local ansi=45
fi
@polarblau
polarblau / config.rb
Created June 12, 2014 07:34
Proxy API requests through e.g. your Middleman to avoid cross domain issues.
class APIProxy
def call(env)
request = Rack::Request.new(env)
api_url = request.params['api_url']
[200, { 'Content-Type' => 'application/json' }, [get_json(api_url)]]
end
private
@polarblau
polarblau / should_be_json.rb
Created June 25, 2014 08:45
Rspec matcher to check if input is JSON.
RSpec::Matchers.define :be_json do
match do |actual|
begin
!!JSON.parse(actual)
rescue
false
end
end
failure_message_for_should do |actual|
@polarblau
polarblau / api_proxy.rb
Created July 10, 2014 08:39
Proxy API request through your server to avoid cross–origin issues.
# USAGE:
#
# Mount endpoint, e.g.:
#
# map '/api_proxy' do
# run APIProxy.new
# end
#
# Then call the endpoint, passing the actual URL
# as GET param `api_url`
function Bar() {}
Bar.prototype.foo = function () {
console.log('Bar#foo called');
};
Bar.prototype.bar = function (arg) {
console.log(this);
console.log('Bar#bar called with ' + arg);
};
.foo {
color: red;
}