Skip to content

Instantly share code, notes, and snippets.

View bobthecow's full-sized avatar

Justin Hileman bobthecow

View GitHub Profile
@popthestack
popthestack / wp-to-nanoc.php
Created April 29, 2012 18:48
Hacked together Wordpress -> Nanoc script
<?php
$db = mysql_connect('localhost', 'db_user', 'db_password');
mysql_select_db('blog');
$sql = "SELECT * FROM wp_posts WHERE post_status IN ('publish', 'private') AND post_type = 'post'";
$r = mysql_query($sql);
get_posts($r);
// do drafts separately in order to keep them from messing with published posts' URLs
@lg0
lg0 / markdown.xml
Created April 10, 2012 19:58
Markdown Syntax Highlighting for Sublime text 2
<!-- copy this to YOUR_THEME.tmTheme-->
<dict>
<key>name</key>
<string>diff: deleted</string>
<key>scope</key>
<string>markup.deleted</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#EAE3CA</string>
@coreyhaines
coreyhaines / .rspec
Last active April 11, 2024 00:19
Active Record Spec Helper - Loading just active record
--colour
-I app
@axelav
axelav / gist:1839777
Created February 15, 2012 22:51 — forked from lucasfais/gist:1207002
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
@ziadoz
ziadoz / awesome-php.md
Last active May 10, 2024 15:06
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.
@fracai
fracai / absolutize_paths.rb
Created January 12, 2012 00:10
nanoc filter to convert relative paths to absolute
# encoding: utf-8
module Nanoc3::Filters
class AbsolutizePaths < Nanoc3::Filter
identifier :absolutize_paths
require 'nanoc3/helpers/link_to'
include Nanoc3::Helpers::LinkTo
@gcollazo
gcollazo / Backbone.sync_csrftoken.js
Created September 25, 2011 14:56
This is what I did to insert the CSRF token in backbone requests. This works with django.
var oldSync = Backbone.sync;
Backbone.sync = function(method, model, options){
options.beforeSend = function(xhr){
xhr.setRequestHeader('X-CSRFToken', CSRF_TOKEN);
};
return oldSync(method, model, options);
};
@sevennineteen
sevennineteen / gist:1224478
Created September 17, 2011 23:14
Set logger level on Heroku Sinatra app
require "logger"
configure do
LOG = Logger.new(STDOUT)
LOG.level = Logger.const_get ENV['LOG_LEVEL'] || 'DEBUG'
LOG.info 'I am logging something.'
end
@onethirtyfive
onethirtyfive / gist:1141150
Created August 12, 2011 00:17
Grape presenters?
# lib/api/presenters/detailed_post.rb
module API
module Presenters
class DetailedPost
include ActiveModel::Serializers::JSON
include ActiveModel::Serializers::Xml
attr_accessor :post
delegate :attributes, :to => :post
@rogerrohrbach
rogerrohrbach / nanp_validator.rb
Created June 27, 2011 14:42
Active Model North American Telephone Number validator
# == Active Model North American Telephone Number Validator
# http://en.wikipedia.org/wiki/North_American_Numbering_Plan#Current_system
# [Author] Roger Rohrbach (roger@ecstatic.com)
class NanpValidator < ActiveModel::EachValidator
def self.matcher(require_area_code) # :nodoc:
%r{
(?<country_code> \+1 ){0}
(?<trunk_prefix> 1 ){0}
(?<delimiter> ([-\.]|\ +) ){0}