Skip to content

Instantly share code, notes, and snippets.

View drfeelngood's full-sized avatar

daniel drfeelngood

  • The streets of OKC
View GitHub Profile
@drfeelngood
drfeelngood / rails_api_pagination.md
Last active August 29, 2015 14:13
Rails API pagination with kaminari using http headers
def respond_with_paginated(collection)
  %w( current_page
      total_pages
      total_count
      prev_page
      next_page
      first_page?
      last_page?
 ).each do |method_name|
@drfeelngood
drfeelngood / net_scp_progress.rb
Created September 25, 2012 19:57
Net::SCP Progress bar
require 'net/scp'
# ... code ...
puts "==> Downloading #{remote_path}"
Net::SCP.download!(hostname, username, remote_path, local_path) do |c,n,r,t|
pct = r / t.to_f
cnt = ( 72 * pct ).ceil
print "%-72s %.2f%%\r" % [ ("#" * cnt), ( pct * 100 ) ]
end
@drfeelngood
drfeelngood / post-receive.rb
Created September 10, 2011 11:15
Git post-receive hook that broadcasts commit messages via jabber
# post-receive
#
# Broadcast commit messages when pushed to the repositories master branch.
#
#== Git Configuration Example
# [notify]
# jabber = foo bar
#
require 'rubygems'
require 'jabber4r/jabber4r'
@drfeelngood
drfeelngood / mongod.sh
Created August 2, 2011 16:33
mongod service script
#!/bin/bash
# mongod
#
# chkconfig: 2345
# description: Scalable, high-performance, open source, document-oriented
# database. Written in C++.
#
# processname: mongod
# pidfile: /var/run/mongod.pid
# config: /etc/mongod.conf
@drfeelngood
drfeelngood / redis.sh
Created August 2, 2011 15:36
redis-server service script
#!/bin/bash
# redis Advanced key-value store
#
# chkconfig: 2345
# description: Redis is an open source, advanced key-value store. It is often
# referred to as a data structure server since keys can contain
# strings, hashes, lists, sets and sorted sets.
# processname: redis-server
# pidfile: /var/run/redis.pid
# config: /etc/redis.conf
@drfeelngood
drfeelngood / sweep-tunes.rb
Created January 9, 2011 20:25
Simple script that helps in migrating mp3 files to one central iTunes library.
#!/usr/bin/env ruby
#= sweep-tunes
require 'rubygems'
require 'broom'
if ARGV.size != 1
puts "usage: sweep-tunes <path>"
exit
end