Skip to content

Instantly share code, notes, and snippets.

@jasoncodes
jasoncodes / keybase.md
Created March 12, 2014 05:29
Keybase proof

Keybase proof

I hereby claim:

  • I am jasoncodes on github.
  • I am jasoncodes (https://keybase.io/jasoncodes) on keybase.
  • I have a public key whose fingerprint is 00FE 9E5D 9F6E DBF2 B03E 971E CA17 A856 9172 8429

To claim this, I am signing this object:

@jasoncodes
jasoncodes / missing_foreign_key_constraints_spec.sql
Created September 1, 2014 04:51
Find missing foreign key constraints
SELECT CONCAT(col.table_name, '.', col.column_name)
FROM information_schema.columns col
INNER JOIN pg_catalog.pg_tables tbl ON tbl.schemaname = col.table_schema AND tbl.tablename = col.table_name
LEFT JOIN information_schema.columns col_type ON (
col.table_schema = col_type.table_schema AND
col.table_name = col_type.table_name AND
regexp_replace(col.column_name, '_id$', '_type') = col_type.column_name
)
LEFT JOIN (
(
@jasoncodes
jasoncodes / fix-bash.sh
Last active August 29, 2015 14:06
Shellshock (CVE-2014-6271 and CVE-2014-7169) patch for OS X 10.9 Mavericks
#!/bin/bash -e
# Shellshock (CVE-2014-6271 and CVE-2014-7169) patch for OS X 10.9 Mavericks
# Based on http://apple.stackexchange.com/a/146851
cd /tmp
mkdir bash-fix
cd bash-fix
curl https://opensource.apple.com/tarballs/bash/bash-92.tar.gz | tar zxf -
cd bash-92/bash-3.2
@jasoncodes
jasoncodes / README
Last active August 29, 2015 14:14
Disable Hyphenation and Justification Bookmarklet
Disables hyphenation and full text justification.
Minified using http://chriszarate.github.io/bookmarkleter/.
keys = [
%w[a 1 x],
%w[a 1 y],
%w[a 2 x],
%w[a 3 x],
%w[a 3 y],
%w[b 3 y],
%w[b 4 z],
]
For <http://bjeanes.com/2009/10/01/code-formatting-in-rss-feeds>:
Firstly, please don't limit your feed to just excerpts. Clicking through to read content is annoying at best (more clicks) and impossible at worst (i.e. offline).
Inline styling of the feed content is a much better idea but still not the best. Markup should be semantic (your current code block are not IMO) and feed readers may not even respect user styles.
I think the markup needs to be fixed so it makes sense semantically. I'm thinking it should be a normal <pre/> with <span/>s for style hooks. To add line numbers, wrap each line in <code/> so we can style each line (unless I'm missing a way to write a selector to match all lines a la ::first-line).
I have quickly thrown together a proof of concept, tested in Safari 4 only. It's roughly styled like your blog with the <pre/> code generated by the TextMate.tmbundle but with manually added <code/> tags. The styling is a good candidate for SASS with all the calculations.
raise "Check if this is still needed on #{Rails.version}" unless Rails.version == '2.3.5'
# <https://rails.lighthouseapp.com/projects/8994/tickets/3208-belongs_to-with-primary_key-does-not-work-with-finds-include>
# this should hopefully be fixed in 2.3.6. Untested on 3.0.
# can't easily patch the output of association_join via a alias_method_chain
# so the whole method is replaced here with the one line fix applied
module ActiveRecord::Associations::ClassMethods
class JoinDependency
class JoinAssociation
class Hash
def selekt
inject({}) {|hsh,(k,v)|
hsh[k] = v if yield(k,v)
hsh
}
end
end
@jasoncodes
jasoncodes / config.ru
Created May 18, 2010 11:29 — forked from toolmantim/config.ru
Serving simple static sites using Rack
# Rackup file for serving up a static site from a "public" directory
#
# Useful for chucking a static site on Heroku
class IndexRewriter
def initialize(app) @app = app end
def call(env)
env["PATH_INFO"].gsub! /\/$/, '/index.html'
@app.call(env)
end
@jasoncodes
jasoncodes / github_clone_all_public.rb
Created June 11, 2010 20:30
A quick script to clone all your public repos on GitHub
#!/usr/bin/env ruby
require 'net/http'
require 'yaml'
username = `git config github.user`.strip
if username.empty?
$stderr.puts "Please set github.user in your git config: https://github.com/account"
exit 1