Skip to content

Instantly share code, notes, and snippets.

View radavis's full-sized avatar

Richard Davis radavis

View GitHub Profile
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Foundation CDN Starter Template</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/foundation/6.2.4/foundation.min.css">
</head>
<body>
@radavis
radavis / rails-4-to-5.md
Last active October 21, 2016 14:52
Upgrading from Rails 4 to 5
  1. bundle

  2. rake rails:update

# Gemfile
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
gem 'pg', '~&gt; 0.18'
# Notes on working with IO objects
require 'pp'
<<-MD
# IO
The basis for all input and output in Ruby (and computers).
Types of IO devices:
@radavis
radavis / convert-cr2.md
Last active February 24, 2016 12:34
Mass converting CR2 files

Mass converting CR2 files

$ brew uninstall imagemagick
$ brew install ufraw ghostscript
$ brew install imagemagick
#!/bin/bash
var newCommentForm = function(element) {
return {
element: $(element),
title: function() {
return this.element.find("#comment_title").val();
},
content: function() {
return this.element.find("#comment_content").val();
},
videoId: function() {
require "open-uri"
# Pull images from markdown files
class Image
class << self
def download
links.each do |link|
filename = link.split("/")[-1]
remote_file = open(link)

Exit out of long-running specs in your RSpec test suite.

# spec_helper.rb

require "timeout"

RSpec.configure do |config|
  config.around(:each) do |example|
 Timeout::timeout(5) {
languages = ["Ruby", "JavaScript", "HTML", "CSS"]
languages.is_a?(Array)
languages.is_a?(Object)
languages.is_a?(BasicObject)
languages.ancestors
class Person # < Object
attr_reader :name
def initialize(name)
@name = name

Saab Stereo Head Unit

Locks itself when battery is disconnected. Can only be unlocked when a code is entered.

Code is based on the combination VIN, Serial Number, and PU Number of the radio.

There is a possibility that the code is written on top of the stereo head unit.

GM Dealers should be able to give you this code over the phone.

Redirect all Requests to Another Application

We recently decommisioned one of our applications after it was replaced with a shiny new one with a new hostname. In order to make the transistion seamless for past users, we needed a way to redirect all traffic to the new URL.

Rails makes this quite easy to do.

class ApplicationController
  before_filter :redirect_all_requests