Skip to content

Instantly share code, notes, and snippets.

View davidfrey's full-sized avatar

David Frey davidfrey

View GitHub Profile
@redoPop
redoPop / .gitignore
Created June 18, 2010 22:08
Template .gitignore file for WordPress projects
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your
#!/usr/bin/env ruby
#
# Originally written by http://redartisan.com/tags/csv
# Added and minor changes by Gavin Laking
# Rewritten by Andrew Bennett for Ruby 1.9
#
# Usage: ruby csv_to_fixture.rb file.csv [--json]
#
# "id","name","mime_type","extensions","icon_url"
# "1","unknown","unknown/unknown","||","/images/icon/file_unknown.gif"
@joshsusser
joshsusser / gist:998055
Created May 29, 2011 19:20
turn off 255 limit for string fields in postgresql
# in rails application.rb
initializer "postgresql.no_default_string_limit" do
ActiveSupport.on_load(:active_record) do
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES[:string].delete(:limit)
end
end
# config.ru for Pow + Wordpress, based on http://stuff-things.net/2011/05/16/legacy-development-with-pow/
# added hackery to work around wordpress issues - Patrick Anderson (patrick@trinity-ai.com)
# added rubygems, replaced script_path with script from path_parts, added to_return to fix return error - Paul Cook
# clearly this could be cleaner, but it does work
require 'rubygems'
require 'rack'
require 'rack-legacy'
require 'rack-rewrite'
@jcasimir
jcasimir / friendly_urls.markdown
Created September 11, 2011 15:48
Friendly URLs in Rails

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.

@bjhess
bjhess / pull_request_webhook.md
Created May 18, 2012 15:58
The way I had to add a github repo webhook for pull requests

This is more complex than necessary.

GitHub webhooks for a URL by default only fire on repo pushes. There appears to be no way in the web UI to set up webhooks for other events. And so we go to the API. I prefer to do this type of thing with Hurl.

{
  "name": "web",
 "active": true,
@clarkdave
clarkdave / pg_enum.rb
Last active July 18, 2019 15:37
basic support for PostgreSQL Enums in ActiveRecord - to be placed in an initializer
##
# This provides `create_enum` and `drop_enum` methods for migrations, which creates
# a Postgres ENUM type with the provided values.
#
# It'll also dump these into the schema.rb to be loaded into another DB (e.g. rake db:test:load)
#
# In order to reference the new enums as actual types, ActiveRecord needs to know about them, so
# make sure they are all represented in the `types` array below
#
# Then you can reference them in your migrations, e.g.
@krambuhl
krambuhl / grid.scss
Last active December 21, 2015 09:28
Sass responsive grid implimentation
$grid-max: 12;
$grid-column: 80px;
$grid-gutter: 0px;
@function gridw ($span: $grid-max, $offset: 0px) {
@return ($grid-column * $span) + ($grid-gutter * ($span - 1)) + $offset;
}
@mixin grid ($span: $grid-max, $offset: 0px) {
width: gridw($span, $offset);
@coreyhaines
coreyhaines / not sure I like this
Last active August 29, 2015 14:16
Using super() in rspec's subject
# Phew! Turns out this was generated by transpec, not by a human!
before do
@admin = User.create(username: "user", password: "password", password_confirmation: "password")
end
subject{ @admin }
describe '#remember_token' do
subject { super().remember_token }
it { is_expected.not_to be_blank }
@simonbasle
simonbasle / collapseAll.js
Last active August 16, 2019 09:13
Collapsing and loading all files in a large pull request, from Chrome Dev Tools
//tested on GitHub 2017-03-24, this collapses all diffs including non-loaded ones
$$('.pr-2').forEach(function(element){if(element.attributes['aria-label'].value == "Toggle diff text") { element.click(); }});