Skip to content

Instantly share code, notes, and snippets.


Frank Kany kany

  • Rickman, TN
View GitHub Profile
dhh / pagination_controller.js
Last active Jan 18, 2022
HEY's Stimulus Pagination Controller
View pagination_controller.js
ERB template chunk from The Feed's display of emails:
<section class="postings postings--feed-style" id="postings"
data-controller="pagination" data-pagination-root-margin-value="40px">
<%= render partial: "postings/snippet", collection: @page.records, as: :posting, cached: true %>
<%= link_to(spinner_tag, url_for(page: @page.next_param),
class: "pagination-link", data: { pagination_target: "nextPageLink", preload: @page.first? }) unless @page.last? %>
kany / formatting_xml_or_json.rb
Created Feb 12, 2019
Formatting XML or JSON
View formatting_xml_or_json.rb
# resource -
# Formatting XML
cat unformatted.xml | xmllint --format - > formatted.xml
# Formatting JSON
cat unformatted.json | python -m json.tool > formatted.json

Rails 5 and ActionCable

Assumptions: The application already exists. You have two models article.rb and comment.rb. Articles have two attributes, title and text. Comments have two attributes, text and article_id. See these instructions if you need help getting started.


Assuming that you are nesting your :comments resources inside of :articles, mount ActionCable and make sure you have a root.


Rails.application.routes.draw do
iamatypeofwalrus /
Last active Oct 9, 2019
Get Glyphicons up and running in Rails 3.2 without using a gem

Getting Glyphicons from Bootstrap 3.0 in Rails: the easy way


Bootstrap 3.0 gives you access to the awesome icon set icon set by these dudes but it's not obvious for a Rails newbie like myself to get it all working together nicely


  1. Download the bootstrap-glyphicons.css from here. Save that file to RAILS_ROOT/vendor/assets/stylesheet/bootstrap-glyphicons.css
  2. Save all the font files in /dist/fonts from the Bootstrap 3.0 download to a new folder in your Rails app RAILS_ROOT/vendor/assets/fonts
  3. Add this folder to the asset pipeline by appending config.assets.paths << Rails.root.join("vendor","assets", "fonts") to application.rb after the line that has class Application < Rails::Application.
  4. In bootstrap-glyphicons.css modify the the `url
iamatypeofwalrus / Bootsrap
Last active May 20, 2019
Add Bootstrap to your Rails app without a Gem
View Bootsrap

Bootstrap 3.0 in Rails without a Gem

What is Bootstrap?

It's a collection of CSS styles and Javascript add-ons that stop your site from looking like a shitty craigslist rip off from 1996. Seriously, who wants that?

Docs: CSS, Components, Javascript

Why Install It This Way?

Finding the right gem, keeping it updated, and learning the syntax is a pain in the ass. Why not install Bootstrap the way you'd install new javascript libraries?

yellow5 / tables_with_foreign_keys.sql
Created Feb 14, 2013
Query to list all foreign keys for a given schema in MySQL.
View tables_with_foreign_keys.sql
SELECT table_name, constraint_name
FROM information_schema.table_constraints
table_schema = 'DATABASE_NAME' AND
constraint_type= 'FOREIGN KEY'
MicahElliott /
Created Apr 17, 2012
Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

This guide enables you to install (ruby-build) and use (rbenv) multiple versions of ruby, isolate project gems (gemsets and/or bundler), and automatically use appropriate combinations of rubies and gems.

TL;DR Demo

# Ensure system is in ship-shape.
aptitude install git zsh libssl-dev zlib1g-dev libreadline-dev libyaml-dev
he9lin /
Created Oct 1, 2011
Setup Rails application production environment on Ubuntu

Setup Rails application production environment on Ubuntu

Add deploy user

adduser deploy
visudo # Add deploy ALL=(ALL) ALL

Install necessary libraries

denmarkin / resque.rake
Created Sep 20, 2011
My rake task for clearing Resque queues and stats
View resque.rake
# see - old version
# see
# see - new commands
namespace :resque do
desc "Clear pending tasks"
task :clear => :environment do
queues = Resque.queues
queues.each do |queue_name|
puts "Clearing #{queue_name}..."
gus / index.txt
Created Nov 30, 2009 — forked from toothrot/index.txt
Ruby/Clojure analogs
View index.txt
For each Ruby module/class, we have Ruby methods on the left and the equivalent
Clojure functions and/or relevant notes are on the right.
For clojure functions, symbols indicate existing method definitions, in the
clojure namespace if none is explicitly given. clojure.contrib.*/* functions can
be obtained from,
ruby-to-clojure.*/* functions can be obtained from the source files in this
If no method symbol is given, we use the following notation: