Skip to content

Instantly share code, notes, and snippets.

eliotsykes /
Last active May 17, 2023 22:13
"rails new" options explained

Run rails new --help to view all of the options you can pass to rails new:

$ bin/rails new --help
  rails new APP_PATH [options]

  -r, [--ruby=PATH]                                      # Path to the Ruby binary of your choice
                                                         # Default: /Users/eliot/.rbenv/versions/2.2.0/bin/ruby
rewonc / app.js
Last active October 26, 2021 00:16
AngularJS/PhoneGap/Ionic: filter to convert links for opening in separate mobile window
View app.js
//* See the JS Fiddle:
// make sure ngSanitize module is installed:
// To convert links from plaintext, you must use the linky filter which is included with ngSanitize
dmilisic / active_record_enum_with_rails_admin.rb
Last active January 21, 2022 10:50
Initializer for handling ActiveRecord (4.1+) enums by RailsAdmin (0.6.2)
View active_record_enum_with_rails_admin.rb
module ActiveRecord
module RailsAdminEnum
def enum(definitions)
definitions.each do |name, values|
define_method("#{ name }_enum") { self.class.send(name.to_s.pluralize).to_a }
define_method("#{ name }=") do |value|
if value.kind_of?(String) and value.to_i.to_s == value
thebucknerlife /
Last active June 1, 2023 21:11
Simple Authentication in Rail 4 Using Bcrypt

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault


naoyeye / angular.filters.nl2br.js
Created January 2, 2014 14:36
angular nl2br filter
View angular.filters.nl2br.js
# Usage in html template:
"xxx | nl2br"
<div ng-bind-html=" YourString | nl2br "></div>
SabretWoW / rspec_model_testing_template.rb
Last active January 19, 2023 18:41
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
View rspec_model_testing_template.rb
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
# @kyletcarlson
# This skeleton also assumes you're using the following gems:
Mao8a / fix-to-iOS-iframe-height-issue.html
Created July 10, 2013 05:21
HTML: Fix to iOS iframe height issue
View fix-to-iOS-iframe-height-issue.html
Fix to iOS iframe height issue
<iframe id="stupid-iframe" height="200" src="a-file.html"></iframe>
<div class="iframe-wrapper" style="width: 100%; height: 200px; overflow: auto; -webkit-overflow-scrolling: touch;">
jareware /
Last active June 1, 2023 05:57
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do

⇐ back to the gist-blog at

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso

ls-lukebowerman / sitemap.xml.erb
Created August 7, 2012 17:59
Sitemap ( generator for Middleman
View sitemap.xml.erb
<% pages = sitemap.resources.find_all{|p| p.source_file.match(/\.html/) } %>
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="">
<% pages.each do |p| %>
<% end %>
dsheiko / strtr.js
Last active May 15, 2023 22:29
Java-script strtr — translate characters or replace substrings
View strtr.js
* strtr() for JavaScript
* Translate characters or replace substrings
* @author Dmitry Sheiko
* @version strtr.js, v 1.0.2
* @license MIT
* @copyright (c) Dmitry Sheiko