Skip to content

Instantly share code, notes, and snippets.

View espen's full-sized avatar

Espen Antonsen espen

View GitHub Profile
@darashi
darashi / git_commit_header.rb
Created May 20, 2009 11:44
add X-Git-Commit header to Rack application
# Rack middleware to insert git commit id into http response header
# For Rails, put this script under RAILS_ROOT/config/initializers
module Rack
class GitCommitHeader
def initialize(app)
@app = app
c = `git rev-parse HEAD`.chomp
@commit = (c =~ /^[0-9a-f]{40}$/) ? c : nil
end
@mikz
mikz / gist:574015
Created September 10, 2010 17:14
def quoted_date(value)
if value.acts_like?(:time) && value.respond_to?(:usec)
begin
"#{value.getutc.to_s(:db)}.#{sprintf("%06d", value.usec)} #{value.formatted_offset}"
rescue
"#{super}.#{sprintf("%06d", value.usec)}"
end
else
super
@JeanMertz
JeanMertz / syntax_highlighting.py
Created April 18, 2011 08:39
Ruby on Rails syntax highlight switcher for Sublime Text 2
import sublime, sublime_plugin
import os
class DetectFileTypeCommand(sublime_plugin.EventListener):
""" Detects current file type if the file's extension isn't conclusive """
""" Modified for Ruby on Rails and Sublime Text 2 """
""" Original pastie here: http://pastie.org/private/kz8gtts0cjcvkec0d4quqa """
def on_load(self, view):
filename = view.file_name()
@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@vagmi
vagmi / pg_application_name_patch.rb
Created May 11, 2012 06:13
Set the application name for a postgres connection in Rails 3
module ActiveRecord
module ApplicationName
def self.included(base)
unless base.respond_to? :establish_connection_with_application_name
base.extend ClassMethods
base.class_eval do
class << self
alias_method_chain :establish_connection, :application_name
end
end
@rkh
rkh / gist:4644647
Last active December 11, 2015 18:49

The Hunt for the right HTTP library

Use case: Travis CLI. One command invokes one or more sequential HTTP requests.

Note that startup time and the first request are very significant for a command line tool like this.

Clone the repo if you want to follow along.

Note: numbers might be due to how libraries are used (via faraday)

@larsw
larsw / lamkarri.md
Last active December 12, 2015 02:58
Wasims #lamkarri

Wasims (@WasimZahid) #lamkarri

Jeg skal nå dele verdens enkleste måte å lage en nydelig pakistansk lammegryte på, helt fra scratch.

  1. Ha 1kg lammekjøtt i biter (gjerne rett fra fryseren) i en middels stor gryte.

  2. Skjær en løk, litt fersk ingefær og hvitløk i fine biter.

@aslakhellesoy
aslakhellesoy / gfm.sh
Last active November 23, 2016 09:57
Compile and show GFM docs in your browser.https://help.github.com/articles/github-flavored-markdown
#!/bin/sh
# Compile and show [GFM](https://help.github.com/articles/github-flavored-markdown) docs in your browser.
# Before this works you need to `gem install bcat`
#
# Usage: gfm.sh FILE.md
#
curl --silent --data-binary @- https://api.github.com/markdown/raw -H "Content-Type: text/plain" | bcat
@benhoskings
benhoskings / ruby-2-cert-issue-fix.sh
Last active March 21, 2016 18:30
Ruby 2.0 CA cert issue fix
# If you're having cert issues on ruby 2.0.0-p0, the issue is most likely that ruby can't
# find the required intermediate certificates. If you built it via rbenv/ruby-build, then
# the certs are already on your system, just not where ruby expects them to be.
# When ruby-build installs openssl, it installs the CA certs here:
~/.rbenv/versions/2.0.0-p0/openssl/ssl/cacert.pem
# Ruby is expecting them here:
$(ruby -ropenssl -e 'puts OpenSSL::X509::DEFAULT_CERT_FILE')
# Which for me, is this path:
@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active November 10, 2024 03:45
A badass list of frontend development resources I collected over time.