Skip to content

Instantly share code, notes, and snippets.

View matthewlehner's full-sized avatar
👻

Matthew Lehner matthewlehner

👻
View GitHub Profile
@matthewlehner
matthewlehner / gist:16fbb3ee2fb7053e2ead
Created July 25, 2015 03:22 — forked from TattdCodeMonkey/gist:e08acb86343bc8e43866
Justin Weiss - Is Rails fast enough?

Is Rails fast enough?

When a new language or web framework pops up, what do you usually see along with it?

Benchmarks. Benchmarks like these.

As a Rails developer, you might be embarassed to see this. I mean, Rails is more than a full order of magnitude slower than Phoenix! And even Sinatra is about 3x faster.

But what do you do about stats like this? Do you shift to another language, so you can get faster response times? Do you move to a different architecture, with some services written in Go, some in Elixir, talking to a frontend in JavaScript? What would you even use Rails for, then?

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.js"></script>
<script src="http://builds.emberjs.com/canary/ember.prod.js"></script>
</head>
@matthewlehner
matthewlehner / compass-retina-sprites.scss
Created August 1, 2012 20:50 — forked from thulstrup/compass-retina-sprites.scss
Using Compass to generate normal and retina sprite maps
$sprites: sprite-map("sprites/*.png");
$sprites-retina: sprite-map("sprites-retina/*.png");
@mixin sprite-background($name) {
background-image: sprite-url($sprites);
background-position: sprite-position($sprites, $name);
background-repeat: no-repeat;
display: block;
height: image-height(sprite-file($sprites, $name));
width: image-width(sprite-file($sprites, $name));
@matthewlehner
matthewlehner / user.rb
Created May 30, 2012 17:47 — forked from andresgutgon/user.rb
Migrate Authlogic SHA512 Passwords to BCryt
# Because we have some old legacy users in the database, we need to
# override #has_secure_passwords' method for checking if a password is valid.
# We first ask if the password is valid, and if it throws an InvalidHash
# exception, we know that we're dealing with a legacy user, so we check the
# password against the SHA1 algorithm that was used to hash the password in
# the old database.
#SOURCES OF SOLUTION:
# http://stackoverflow.com/questions/6113375/converting-existing-password-hash-to-devise
# https://github.com/binarylogic/authlogic/blob/master/lib/authlogic/crypto_providers/sha512.rb
@matthewlehner
matthewlehner / nesting.coffee
Created March 7, 2012 00:41 — forked from lagartoflojo/nesting.coffee
Helper function for nesting Backbone collections (CoffeeScript version)
Backbone.Model::nestCollection = (attributeName, nestedCollection) ->
#setup nested references
for item, i in nestedCollection
@attributes[attributeName][i] = nestedCollection.at(i).attributes
#create empty arrays if none
nestedCollection.bind 'add', (initiative) =>
if !@get(attributeName)
@attributes[attributeName] = []
@get(attributeName).push(initiative.attributes)
@matthewlehner
matthewlehner / nesting.js
Created March 7, 2012 00:39 — forked from geddski/nesting.js
helper function for nesting backbone collections.
function nestCollection(model, attributeName, nestedCollection) {
//setup nested references
for (var i = 0; i < nestedCollection.length; i++) {
model.attributes[attributeName][i] = nestedCollection.at(i).attributes;
}
//create empty arrays if none
nestedCollection.bind('add', function (initiative) {
if (!model.get(attributeName)) {
model.attributes[attributeName] = [];
require "config/environment"
count = Rim.count
Rim.all.each_with_index do |rim, i|
if rim.rim_photo.file?
puts "rim #{i} of #{count} +"
rim.photo = File.open((Rails.root.to_s + '/public' + rim.rim_photo.url).split("?").first)
rim.save
else
puts "rim #{i} of #{count} -"