Skip to content

Instantly share code, notes, and snippets.

View justinperkins's full-sized avatar
🥶

Justin Perkins justinperkins

🥶
View GitHub Profile
@justinperkins
justinperkins / pre-push
Last active September 14, 2022 15:19
Git pre push hook for branch naming convention validation
#!/usr/bin/env ruby
local_branch = `git rev-parse --abbrev-ref HEAD`.chomp
valid_branch_regex = /^(task|chore|feature|fix|text|hotfix|release)\/[a-z0-9._-]{2,30}$/
if local_branch =~ valid_branch_regex
exit 0
else
puts "Branch name does not match our convention, please make sure it follows this pattern: #{valid_branch_regex}"
@justinperkins
justinperkins / lost-disc-found.txt
Last active February 22, 2022 17:58
Disc Return Info
Looks like you found one of my discs with a QR code on it! Thanks for taking the time to scan it and read this page.
I love getting my discs back when I've lost or forgotten them. I always offer a reward in the form of a disc or two from my disc storage in exchange for getting my disc back.
Since this page is public, I'm not including my phone number.
Email me here: discreturn@tacofan.com
Include your phone # if you want and I'll text you since that's probably easier
require 'test_helper'
class ServiceTest < ActiveSupport::TestCase
def setup
super
@klass = Class.new do
include Service
class Event
def initialize
@callbacks = {}
end
def on(event, &block)
@callbacks[event] ||= []
@callbacks[event] << block
end
@justinperkins
justinperkins / jquery-auth-token.js
Created October 26, 2012 17:48
Put auth-token on all jQuery Ajax Requests
$(function(){
var tokenValue = $("meta[name='csrf-token']").attr('content');
$.ajaxSetup({
headers: {'X-CSRF-Token': tokenValue}
});
})
@justinperkins
justinperkins / gist:3909887
Created October 18, 2012 04:40
Backbone.js + Rails: Add Auth Token to Sync
// Adapted from: https://gist.github.com/1251730
// I like this technique better: https://gist.github.com/3960219
$(function(){
var paramName = $("meta[name='csrf-param']").attr('content');
var paramValue = $("meta[name='csrf-token']").attr('content');
Backbone.sync = _.wrap(Backbone.sync, function(originalSync, method, model, success, error){
if (method == 'create' || method == 'update' || method == 'delete') {
// grab the token from the meta tag rails embeds
@justinperkins
justinperkins / cookie.js
Created September 7, 2012 19:33 — forked from ChillyBwoy/cookie.js
Cookie functions for underscore.js
tt http://trac/cgi-bin/trac.cgi/ticket/%s Jump To Trac Ticket
tc http://trac/cgi-bin/trac.cgi/changeset/%s Jump To Trac Commit
tp http://trac/cgi-bin/trac.cgi/browser/%s Jump To Trac Path
am http://www.allmusic.com/cg/amg.dll?SQL=%s&OPT1=1&Submit=Go&P=amg Search AllMusic
movies http://www.google.com/movies?sc=1&near=%s&rl=1 Google Movies
#!/usr/bin/env ruby
#######################
# description:
# sends an email to one or more people on a certain day of the week, which rotates every week
# an email is sent on monday to advise your recipients which day of the week the taco day falls on
# then on the day of the taco day, a brief email will be sent to remind people once again
# use cron to schedule this script to be invoked on weekdays at whatever time you want the email to be sent
# here is an example: 0 11 * * 1-5 ~/bin/taco-mailer.rb
#######################
#!/usr/bin/env ruby
require 'rubygems'
=begin
TimeTracker is a simple way to track time on tasks
Start tracking time: ./time_tracker.rb -s some-task-name
Stop tracking time: ./time_tracker.rb -f
View recorded time for a task: ./time_tracker.rb -h some-task-name