Skip to content

Instantly share code, notes, and snippets.

View maxwell's full-sized avatar
🦁
chillin

Maxwell Salzberg maxwell

🦁
chillin
View GitHub Profile
@maxwell
maxwell / rspec
Last active April 21, 2016 00:16
Fix using spring from command line and RubyMine
#got this error in your Rubymine Test runner, and have to "spring stop" all the time?
#/Users/maxwell/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:247:in `require': cannot load such file -- teamcity/spec/runner/formatter/teamcity/formatter (LoadError)
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
require 'bundler/setup'
import random, time, os
timestorun = 100
string = ""
capson = 0
def makemore(letter, freq):
global string
if random.random() < freq:
string = string + letter
makemore(letter, freq)
@maxwell
maxwell / Gemfile
Created July 4, 2013 20:20
BackerKits WIP rails4 gemfile, for trying to track down this: https://github.com/rails/rails/issues/10507 If you see this bug, share your Gemfile and maybe we can figure out where this is happening.
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.0.0'
gem 'rails_autolink'
gem 'protected_attributes'
filepicker.uploadFile(evt.target, function(data){
var filename = data.url + '+' + data.data.filename
$("form input[name='photo[image_url]']").val(filename)
that.$("form").submit();
});
@maxwell
maxwell / reddit.rb
Created July 31, 2012 21:34
the reddit hot alg in ActiveRecord Postgres for rails
class Story < ActiveRecord::Base
# make likes count whatever basic score you want. it would be the sum of up plus down votes, or use whatever cache counters you have and weight them accordingly.
#the magic time should just be a unix time right before people started making stuff, for us, its just 6 months before we started makr.io
def self.ranked
order("(ln( 1 + posts.likes_count) + (EXTRACT(EPOCH FROM created_at) - 1327654606)/9000) desc")
end
@maxwell
maxwell / rasterize.js
Created May 25, 2012 03:10
the perfect raster.js
var page = new WebPage(),
address, output, div;
if (phantom.args.length < 2 || phantom.args.length > 4) {
console.log('Usage: rasterize.js URL filename div');
phantom.exit();
}
address = phantom.args[0];
output = phantom.args[1];
maxwell: silly question: would a static linux build reduce the phantomjs /bin + /lib file size?
[1:56pm] maxwell: I am trying to package different binaries into gems
[1:56pm] maxwell: for heroku, but it seems the linux version increases my slug size by 50megs
[2:20pm] kanzure: kenperkins: --web-security=no should be for XSS not local POSTs
[2:21pm] kanzure: maxwell: err don't you mean "would a dynamically linked library decrease the size?" because statically linked is almost always larger
[2:21pm] maxwell: yeah, that was my understanding as well
[2:21pm] maxwell: but looking at the mac bin and lib
[2:21pm] maxwell: its about 10mb
[2:21pm] maxwell: but for the linux bin and lib
[2:21pm] maxwell: its like 35
describe ApplicationController do
controller do
def index
#do nothing other than filters
end
end
describe "#set_locale" do
it 'prefers a param passed to the page'
@maxwell
maxwell / application.yml
Created April 13, 2012 23:55 — forked from DeadSuperHero/application.yml
AppConfig Proposal #2
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
defaults: &defaults
######################################################
# Environment Configuration
######################################################
@maxwell
maxwell / gist:2353022
Created April 10, 2012 17:23
more backtraces
vendor/bundle/ruby/1.9.1/gems/i18n-0.6.0/lib/i18n/backend/pluralization.rb:37:in `pluralize'
vendor/bundle/ruby/1.9.1/gems/i18n-0.6.0/lib/i18n/backend/base.rb:40:in `translate'
vendor/bundle/ruby/1.9.1/gems/i18n-inflector-2.6.6/lib/i18n-inflector/backend.rb:74:in `translate'
lib/i18n_interpolation_fallbacks.rb:10:in `block in translate'
lib/i18n_interpolation_fallbacks.rb:8:in `each'
lib/i18n_interpolation_fallbacks.rb:8:in `translate'
vendor/bundle/ruby/1.9.1/gems/i18n-0.6.0/lib/i18n/backend/fallbacks.rb:44:in `block (2 levels) in translate'
vendor/bundle/ruby/1.9.1/gems/i18n-0.6.0/lib/i18n/backend/fallbacks.rb:43:in `catch'
vendor/bundle/ruby/1.9.1/gems/i18n-0.6.0/lib/i18n/backend/fallbacks.rb:43:in `block in translate'
vendor/bundle/ruby/1.9.1/gems/i18n-0.6.0/lib/i18n/backend/fallbacks.rb:42:in `each'