Skip to content

Instantly share code, notes, and snippets.

View jeffrafter's full-sized avatar
You are amazing

Jeff Rafter (he/him) jeffrafter

You are amazing
View GitHub Profile
@jeffrafter
jeffrafter / sidekiq_inspect.rb
Created August 14, 2014 00:16
Want to inspect your Sidekiq queues?
def fetch_contents(queue = "default", max = 100000)
Sidekiq.redis do |r|
r.lrange("queue:#{queue}", 0, max)
end;
end
def sidekiq_job_breakdown(queue = "default", contents = nil)
re = /\"class":"([0-9A-Za-z_::]+)"/
contents ||= fetch_contents(queue)
@jeffrafter
jeffrafter / FunWithNSCursor.m
Last active August 29, 2015 13:59
FunWithNSCursor.m
- (void)cursorUpdate:(NSEvent *)theEvent {
[self.cursor set];
}
- (void)resetCursorRects
{
// ...
}
- (NSImage *)cursorImage
# https://gist.github.com/mattetti/7624413
#
# Hack to change the Rails cookie serializer from Marshal to JSON and therefore allow the session
# to be shared between different languages but also avoid that someone knowing the
# cookie secret key could execute arbitrary code on the server by unmarshalling
# modified Ruby code added to the session/permanent cookie.
#
# Note that all users will need to login again since both the remember me cookie and the session cookies
# won't be valid. Note also that the remember me cookie is tested multiple times per request even when it fails.
# for performance reasons you might want to delete it if these extra cycles are too costly for you.
@jeffrafter
jeffrafter / assets.rake
Created October 11, 2013 04:27
Asset precompile and upload task
Rake::Task['assets:precompile:all'].clear
namespace :assets do
namespace :precompile do
task :all do
Rake::Task['assets:precompile:primary'].invoke
# ruby_rake_task("assets:precompile:nondigest", false) if Rails.application.config.assets.digest
end
end
end
@jeffrafter
jeffrafter / growth.md
Last active December 21, 2015 07:38 — forked from kneath/growth.md

Hack on github.com with Kyle Neath

At GitHub, they've set out to GitHub be the best place to share code with friends, co-workers, classmates, and complete strangers.

Already, over three million people use GitHub to build amazing things together.

But that isn't enough. Everyone should enjoy the benefits of Git and everyone should Fork everything.

It turns out GitHub needs your help. You can be GitHub's partner in crime to help Kneath out.

@jeffrafter
jeffrafter / gist:6123920
Created July 31, 2013 17:02
Loading data infile...
LOAD DATA INFILE "~/some_dump.csv" INTO TABLE some_table
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES;
@jeffrafter
jeffrafter / README
Created July 23, 2013 01:25
Fonts... leptonica, jbig2enc, tesseract and you
1. brew install ghostscript
2. Download leptonica: http://code.google.com/p/leptonica/downloads/detail?name=leptonica-1.69.tar.bz2
tar xvzf leptonica-1.69.tar.bz2
cd leptonica-1.69
./configure
make
make install
@jeffrafter
jeffrafter / gist:5968035
Created July 10, 2013 16:55
Oh Hey. In Slack.
var channels = [];
$('a.channel_name').each(function() {
channels.push($(this).attr('href').replace('/channels/', ''));
});
function ohey() {
setTimeout(function() {
if (channels.length == 0) return;
@jeffrafter
jeffrafter / slack.js
Last active December 19, 2015 06:09
A Theme for Slack or This is my theme for English B.
// What?! http://stackoverflow.com/a/5571069/700536
function multiline(f) {
return f.toString().
replace(/^[^\/]+\/\*!?/, '').
replace(/\*\/[^\/]+$/, '');
}
var overrides = multiline(function() {/*!
#messages_container {
background-color: #dfdfdf;
@jeffrafter
jeffrafter / open_sku.osa
Created April 16, 2013 17:30
Automator script to open a SKU. Complete with nifty regex.
on run {input, parameters}
display alert input    
set regex to "echo \"" & input & "\"|grep -Eow \"[0-9]{9}-[0-9]{2}\"" as string
   
set url_path to do shell script regex
   
open location "https://wantful.com/products/" & url_path
   
end run