Skip to content

Instantly share code, notes, and snippets.

View jeremywrowe's full-sized avatar
❤️
Coding

Jeremy W. Rowe jeremywrowe

❤️
Coding
View GitHub Profile
@jeremywrowe
jeremywrowe / Rakefile
Created February 16, 2014 03:06
Jekyll Rake task for making a new post
desc 'creates a new post prefixed with the current date'
task :post, :name, :title, :categories do |task, args|
File.open(File.join('_posts', Time.now.strftime("%Y-%m-%d-#{args[:name].split(' ').join('-')}.markdown")), 'w') do |file|
file << <<-DOC
---
layout: post
title: "#{args[:title].downcase}"
date: #{Time.now.strftime("%Y-%m-%d-%H:%M:%S")}
categories: #{args[:categories].downcase}
---
@jeremywrowe
jeremywrowe / class_level_privates.rb
Created February 22, 2014 01:33
I see the top implementation of class level private methods a lot. Please understand that the private means nothing in that case. Do you know why? :)
# The wrong way to make a class level method private
class Foo
def self.bar
p "bar"
end
private
def self.baz
@jeremywrowe
jeremywrowe / clogs.zsh.sh
Created March 16, 2014 22:57
ZSH function to truncate Rails logs
function clogs() {
if [[ -d log ]]; then
echo 'cleaning logs'
: > log/*.log
else
echo 'logs dir not found'
fi
}
class Base
DEFAULT_PROC = -> () {}
def initialize(api_key, connection_class = External::Service, builder = -> (klass, key) { klass.new(key) })
@api_key = api_key
@builder = builder
@connection_class = connection_class
end
def execute(&block)
@jeremywrowe
jeremywrowe / grouping.rb
Created November 24, 2014 00:41
MySql Group Concat
Customer.joins(subscriptions: :product).group(:email).select('GROUP_CONCAT(DISTINCT subscriptions.state SEPARATOR ":::") AS states, GROUP_CONCAT(DISTINCT products.name SEPARATOR ":::") AS product_names, first_name, last_name').last.states
RSpec.configure do |c|
if c.respond_to?(:default_color=)
c.failure_color = :green
c.success_color = :green
end
end
@jeremywrowe
jeremywrowe / gist:4755a9558b594c231313
Last active August 29, 2015 14:19
config/environment.js
var fs = require('fs'),
path = './bower_components/fontawesome/scss/_icons.scss',
regex = /\.#{\$fa-css-prefix}([-|\w]+):before/g,
match,
data;
ENV.APP.awesomeness = [];
data = fs.readFileSync(path, 'utf8');
while(match = regex.exec(data)) {
@jeremywrowe
jeremywrowe / Brocfile.js
Last active August 29, 2015 14:19
Font-Awesomeness Brocfile.js
var EmberApp = require('ember-cli/lib/broccoli/ember-app'),
app = new EmberApp()
files = require('broccoli-static-compiler'),
trees = require('broccoli-merge-trees');
var fonts = files('./bower_components/fontawesome/fonts', {
srcDir: '/',
files: ['*'],
destDir: '/fonts'
});
@jeremywrowe
jeremywrowe / .vimrc
Created August 30, 2015 18:09
vim config
set nocompatible
set shell=/bin/bash
if filereadable(expand("~/.vimrc.bundles"))
source ~/.vimrc.bundles
endif
if (&t_Co > 2 || has("gui_running")) && !exists("syntax_on")
syntax on
endif
@jeremywrowe
jeremywrowe / autotest.rake
Created December 19, 2010 18:11
autotest ruby script runner for rails (script/autotest), with matching autotest.rake file (lib/tasks/autotest.rake)
$here = File.expand_path(File.dirname(__FILE__))
$rails_root = "#{$here}/../.."
$logs = "#{$rails_root}/logs/"
$script = "#{$rails_root}/script/autotest"
namespace :autotest do
desc "start autotest background task"
task :start do