Skip to content

Instantly share code, notes, and snippets.

jrom

Keybase proof

I hereby claim:

  • I am jrom on github.
  • I am jrom (https://keybase.io/jrom) on keybase.
  • I have a public key ASDS-TzWEf6vEmKDv_aDjpRTh8xvOKVyWxLpLr8EJyHorAo

To claim this, I am signing this object:

@jrom
jrom / datamodel.rake
Created November 23, 2016 12:20
Data model for Rails app using rails_erd
namespace :datamodel do
desc 'Generates data model in erd.pdf'
task :generate do
#say 'Loading application environment...'
Rake::Task[:environment].invoke
require 'rails_erd/diagram/graphviz'
#say 'Loading all models...'
Rails.application.eager_load!
::Rails::Engine.subclasses.map(&:instance).map {|e| e.class.eager_load!}
var local_hash = window.location.hash.substr(1),
hash_value = local_hash.substr(local_hash.indexOf(key + '=')).split('&')[0].split('=')[1],
Data = {};
// Once OAuth handshake is done, we'll be redirected with a hash string in the location that we'll use to extract the token
if (hash_value) {
Data.access_token = hash_value;
call_api("organizations", {}, function (data) {
console.log(data); // Here you have your organizations
@jrom
jrom / status.sh
Created March 14, 2013 12:46
Find status aggregated count for nginx logs
sudo cat /var/log/nginx/access.log | cut -f 9 -d" " | sort | uniq -c
@jrom
jrom / sshd_config
Created January 21, 2013 17:56
SSHD Config to avoid frozen capistrano deploys
# /etc/ssh/sshd_config
TCPKeepAlive yes
ClientAliveInterval 15
ClientAliveCountMax 5
@jrom
jrom / screen.sh
Created December 6, 2012 23:03
How to use screen
screen # Starts a screen session
<C-a d> # Detaches from the screen session
screen -r # Reattaches to a detached session
screen -S paco # Starts a screen session called "paco"
screen -r paco # Reattaches to a detached session called "paco"
@jrom
jrom / creditcard.coffee
Created May 11, 2012 13:36
Credit Card number validation in Coffee Script
# Ported from https://github.com/jzaefferer/jquery-validation/blob/master/jquery.validate.js
creditcard = (value) ->
# accept only spaces, digits and dashes
if /[^0-9 \-]+/.test(value)
return false
nCheck = 0
nDigit = 0
bEven = false
@jrom
jrom / remove_jobs.rb
Created March 15, 2012 15:55
Remove resque jobs if match a condition
def remove_failed_jobs_if(&block)
i = 0
while i < Resque::Failure.count
job = Resque::Failure.all(i)
if yield job
Resque::Failure.remove(i)
else
i += 1
end
end
@jrom
jrom / emoji-plugin.js
Created March 7, 2012 11:37
Emoji plugin for Talker
plugin.onMessageInsertion = function (event) {
var content;
content = Talker.getLastInsertion().replace(/:[\w_+]+:/g, function (match) {
var emoji = match,
filename = (emoji == ':+1:' ? ':plus1:' : emoji).replace(/:/g, '');
return "<img class=\"emoji\" title=\"" + emoji + "\" alt=\"" + emoji + "\" height=\"20\" width=\"20\" align=\"absmiddle\" src=\"https://teambox.com/assets/emojis/" + filename + ".png\">"
});
return content;
};
@jrom
jrom / nginx.conf
Created February 7, 2012 17:14
nginx hack for multiple conditions
if ($request_uri = /) {
set $test A;
}
if ($host ~* teambox.com) {
set $test "${test}B";
}
if ($http_cookie !~* "auth_token") {
set $test "${test}C";