Skip to content

Instantly share code, notes, and snippets.

View kstevens715's full-sized avatar

Kyle Stevens kstevens715

View GitHub Profile
@kstevens715
kstevens715 / _breadcrumbs.html.erb
Created May 16, 2012 00:47
Generates Twitter Bootstrap compatible breadcrumbs with the Crummy gem.
<% render_crumbs do |crumbs| %>
<ul class="breadcrumb">
<% crumbs.each_with_index do |crumb, index| %>
<li>
<% if index < crumbs.size - 1 %>
<%= link_to *crumb %>
<span class="divider">/</span>
<% else %>
<li class="active"><%= crumb[0] %></li>
<% end %>
@kstevens715
kstevens715 / address_controller.rb
Created June 2, 2012 01:03
CoffeeScript file for working with Twitter Bootstrap forms.
# This is just a basic sample of a controller needed to work with popups.js
class AddressesController < ApplicationController
before_filter :load_addressable
def new
@address = @addressable.addresses.build(:name => params[:name])
render :partial => 'form'
end
@kstevens715
kstevens715 / active_record.rb
Created June 20, 2012 14:34
A monkey patch for Rails to fix SchemaDumper to not include table_name_prefix. Will probably be fixed in Rails soon, but needed this now. Based on PR: https://github.com/kennyj/rails/commit/211dcdeaa922c74ac20d274308fb5d41ad490194
# config/initializers/active_record.rb
# Loads the monkey patch.
require 'active_record'
require 'active_record/schema_dumper'
require 'schema_dumper'
ActiveRecord::SchemaDumper.class_eval do
include Nepco::SchemaDumper
end
@kstevens715
kstevens715 / quantum_view.xml
Created November 21, 2012 13:41
Shows how to use the QVNOption in Worldship to use Quantum View notifications. For my future reference.
<ShipmentInformation>
<ShipperNumber>#####</ShipperNumber>
<ServiceType>GND</ServiceType>
<NumberOfPackages>1</NumberOfPackages>
<BillingOption>PP</BillingOption>
<QVNOption>
<QVNRecipientAndNotificationTypes>
<EMailAddress>example@example.com</EMailAddress>
<Ship>Y</Ship>
<Exception>Y</Exception>
@kstevens715
kstevens715 / pagination_view.js.coffee
Created December 25, 2012 03:08
Ember.js AJAX table pagination helper using Twitter Bootstrap. Assumes an ArrayController is in place that implements refreshData(page_num). Replace `Nepco` with [YOURAPPNAME], and in the view with your table add `{{view [YOURAPPNAME].PaginationView}}`. Lots of work to be done still. Plan on having this just be one component in a generic Datatab…
###
Twitter Bootstrap compatible pagination view.
Relies on an ArrayController being in place that implements
refreshData(page_num)
###
# Names of previous and next buttons can be adjusted:
PREV = "Prev"
NEXT = "Next"
@kstevens715
kstevens715 / throttle.sh
Created January 22, 2013 20:51
Throttle your loopback interface in Linux to test low bandwith. I was testing an AJAX file upload progress bar and found this helpful.
# Throttle LO interface
sudo tc qdisc add dev lo root handle 1: htb default 12
sudo tc class add dev lo parent 1:1 classid 1:12 htb rate 20kbps ceil 20kbps
sudo tc qdisc add dev lo parent 1:12 netem delay 1000ms
# Go back to the way things were.
sudo tc qdisc del dev lo root
@kstevens715
kstevens715 / mfcj835dw.sh
Created April 28, 2013 01:31
Script to install an MFC-J835DW printer on a 64-bit instal of Ubuntu 13.04. Should be compatible with earlier versions as well.
#!/usr/bin/env bash
# Step 5b. (for Network Connection) Configure your printer on the cups web interface
# 5b-1. Open a web browser and go to "http://localhost:631/printers".
# 5b-2. Click "Modify Printer" and set following parameters.
#
# - "LPD/LPR Host or Printer" or "AppSocket/HP JetDirect" for Device
# - lpd://192.168.1.8/binary_p1 for Device URI
# - Brother for Make/Manufacturer Selection
# - Your printer's name for Model/Driver Selection
@kstevens715
kstevens715 / route.sh
Created November 2, 2013 12:52
Access IRC while on VPN
sudo route add -host irc.freenode.net gw 192.168.1.1
@kstevens715
kstevens715 / swap.sh
Created November 6, 2013 20:41
Create swap space of 2GB.
#!/usr/bin/env bash
# Exit on any error (non-zero return code)
set -e
# Create swapfile of 2GB with block size 1MB
/bin/dd if=/dev/zero of=/swapfile bs=1024 count=2097152
# Set up the swap file
/sbin/mkswap /swapfile
@kstevens715
kstevens715 / irc.sh
Created November 9, 2013 13:45
Route IRC around VPN (Freenode doesn't like VPN).
sudo route add -host irc.freenode.net gw 192.168.1.1