Skip to content

Instantly share code, notes, and snippets.

View olivierlacan's full-sized avatar

Olivier Lacan olivierlacan

View GitHub Profile
@wesgarrison
wesgarrison / gist:3921560
Created October 20, 2012 01:10
October 19 2012 - rubygems.org - notes on server

[transcript from http://www.youtube.com/watch?v=z73uiWKdJhw and irc]

Why is the server unhappy?

  • Bundle API is 70%-80% of traffic and it has to resolve the dependency graph and Marshal
  • x Processes are spinning in Ruby with 380% (of 400% total CPU [4 x 100%])
  • x Bundle can only use vanilla gems, so that's why we have to use Marshal
  • Redis Heapsize
  • Diskspace

Timing - middle of the day US

@todd
todd / 2.0.0-preview1.sh
Created November 2, 2012 02:01
Shell Script to Install Ruby-2.0.0-preview1 with rbenv
curl https://raw.github.com/gist/3998177/0ac991d732fbfba9f3d8cfd14b861461ef2d9393/2.0.0-preview1 > /tmp/2.0.0-preview1
rbenv install /tmp/2.0.0-preview1
# Rack HoneyToken Middleware
#
# Honey Tokens are unique and unlikely values that should be planted in various
# places within your web application to assist in the detection of a security
# breach. They are useful at trying to detect SQL injection attacks where the
# intended logic of an SQL query is bypassed and the HTTP request is used to
# attempt to download private data instead for example the users or accounts
# table and associated password hashes.
#
# Below is an example of creating three fake users with their password hashes
@olivierlacan
olivierlacan / 1_poltergeist_flash.rb
Last active December 11, 2015 16:59
Poltergeist has a neat but unintuitive way of returning cookies from `page.driver.cookies` or `Capybara.current_session.driver.cookies`, here's how you get them to play nice with assertions in RSpec integration specs using Capybara for example.
module PoltergeistFlash
module TestHelpers
def flash_cookie
cookie = CGI.unescape Capybara.current_session.driver.cookies["flash"].value
return {} unless cookie
JSON.parse(cookie).with_indifferent_access
rescue JSON::ParserError
{}
end
end
@parndt
parndt / gist:4660837
Last active December 11, 2015 21:09
Devise multi-patcher
# config/initializers/devise_patch.rb
require 'devise/version'
if !defined?(Devise::VERSION) || (Devise::VERSION < "1.4.0" && %w[1.2 1.3].all? {|v| !Devise::VERSION.start_with?(v)})
raise "I don't know how to patch your devise version. See http://blog.plataformatec.com.br/2013/01/security-announcement-devise-v2-2-3-v2-1-3-v2-0-5-and-v1-5-3-released/"
end
if Devise::VERSION < "1.5.0"
warn "Patching devise #{Devise::VERSION} with < 1.5.0 patch"
Devise::Models::Authenticatable::ClassMethods.class_eval do
def auth_param_requires_string_conversion?(value); true; end
@yooosef
yooosef / UVSummit_2013.md
Last active December 15, 2015 06:39
UserVoice Summit 2013

Richard White: The Future of Customer Care & UserVoice 2.0

  • 363 people see a UV widget every second, 9+ million a month
  • Another UserConf SF in October 2013
  • Customer retention is the new acquisition: Former thinking was customer acquisition was important (LivingSocial, GroupOn). Subscription based economy you have to keep them coming back each month.
  • Service is part of your product, cannot be separate. Best service is service that is integrated into your product.
  • Customer portal is dead, the app is where your users are.
  • Proactively solicit input from users.
  • Focus your customer engagement around meaningful engagement
  • Meaningful engagement needs meaningful analytics
  • New product: 1. Instant Answers. 2. Satisfaction Scores. An expanded feedback tool. A single bedrock metric for analyzing customer satisfaction. 3. SmartVote. Improves upon the forum. 35 times more users engaged vs. the traditional UV feedback forum. Twice more feedback per user. Engagement per user is much higher.
@courtenay
courtenay / STDOUT
Last active December 16, 2015 15:19
add the "<a name" and span icon there as well, so you can style it with a cute little hoverable link
# output
> gh = Redcarpet::Render::GithubStyleTitles.new
> puts Redcarpet::Markdown.new(gh).render "test\n\n# test 1\n\n# test 2\n\n# test 1\n\n# test 1"
=>
<a name="test-1" class="anchor" href="#test-1"><span class="anchor-icon"></span></a><h1 id="test-1">test 1</h1>
<a name="test-2" class="anchor" href="#test-2"><span class="anchor-icon"></span></a><h1 id="test-2">test 2</h1>
@tylerhunt
tylerhunt / application_controller.rb
Last active December 18, 2015 12:39
Modify Rails view binding to allow values to be explicitly exposed to the views and telling the instance variables to GTFO.
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
def render(*args)
options = args.extract_options!
options[:locals] ||= @_exposed
super *args, options
end
def view_assigns
@steveklabnik
steveklabnik / rails4gems.md
Last active December 19, 2015 13:19
Gems that may not be rails 4 compatible

Gems that need help with Rails 4

  • cucumber-rails
  • simple_form - has a 3.0.0.rc but it depends on rails 4.0.0.rc1
  • delayed_job_active_record - has a v4.0.0.beta3 so likely ready to release soon
  • spork-rails - has no indication of even a beta for rails 4
  • authlogic: binarylogic/authlogic#368
  • activeadmin/activeadmin#1963
@ericboehs
ericboehs / gist:7125105
Created October 23, 2013 19:30
Poltergeist hack to silence CoreText performance notes from phantomjs
module Capybara::Poltergeist
class Client
private
def redirect_stdout(to)
prev = STDOUT.dup
prev.autoclose = false
$stdout = to
STDOUT.reopen(to)
prev = STDERR.dup