Skip to content

Instantly share code, notes, and snippets.

View lukaszx0's full-sized avatar

Lukasz Strzalkowski lukaszx0

  • Column
View GitHub Profile
Ruby 2.1.0 in Production: known bugs and patches
Last week, we upgraded the github.com rails app to ruby 2.1.0 in production.
While testing the new build for rollout, we ran into a number of bugs. Most of
these have been fixed on trunk already, but I've documented them below to help
anyone else who might be testing ruby 2.1 in production.
@naruse I think we should backport these patches to the ruby_2_1 branch and
release 2.1.1 sooner rather than later, as some of the bugs are quite critical.
I'm happy to offer any assistance I can to expedite this process.
@chrishunt
chrishunt / config.ru
Created December 27, 2013 15:37
Debug HTTP Server
run -> (_) { [ 200, { 'Content-Type' => 'text/html', }, ['success'] ] }

A future version of Ember will come with a new templating engine known as HTMLBars.

The original motivation for HTMLBars was to allow helpers and properties to have better contextual information about what they were bound to.

So for example, consider a template like this:

<a href="{{url}}">{{link}}</a>
@pixeltrix
pixeltrix / comparison.rb
Last active December 31, 2015 17:39
Comparison of functional tests vs. integration tests using current implementation and a simple implementation using Rack::Test
require 'benchmark/ips'
require "action_controller/railtie"
class BlogApplication < Rails::Application
config.eager_load = false
config.root = File.dirname(__FILE__)
config.session_store :cookie_store, key: 'session'
config.secret_key_base = 'secret'
end
@hgfischer
hgfischer / benchmark+go+nginx.md
Last active January 6, 2025 09:05
Benchmarking Nginx with Go

Benchmarking Nginx with Go

There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.

So, these are the different settings we are going to compare:

  • Go HTTP standalone (as the control group)
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI
@pch
pch / assert_queries.rb
Last active October 29, 2022 21:13
assert_queries - rails 4
# Assertion for checking the number of queries executed within the &block
def assert_queries(num = 1, &block)
queries = []
callback = lambda { |name, start, finish, id, payload|
queries << payload[:sql] if payload[:sql] =~ /^SELECT|UPDATE|INSERT/
}
ActiveSupport::Notifications.subscribed(callback, "sql.active_record", &block)
ensure
assert_equal num, queries.size, "#{queries.size} instead of #{num} queries were executed.#{queries.size == 0 ? '' : "\nQueries:\n#{queries.join("\n")}"}"
@mattetti
mattetti / rails_encryptor_reduction.rb
Last active December 29, 2015 16:28
Quick high level rundown showing how Rails 4 sets the message encryptor used for sessions, signed messages and more.
require "active_support"
require "active_support/key_generator"
require "json"
# Based on https://gist.github.com/mattetti/7624413
module JsonSessionSerializer
def self.load(value)
begin
JSON.parse(value)
rescue JSON::ParserError
@wsargent
wsargent / docker_cheat.md
Last active June 29, 2024 19:32
Docker cheat sheet
@xaviershay
xaviershay / build_frontend.sh
Last active December 24, 2015 20:49
SASS + Coffee + Concatenation in prod
#!/bin/bash
set -exo pipefail
BUILD_ENV=$1
if [ `uname` == 'Darwin' ]; then
OSX=1
JSCOMPRESSOR="yuicompressor --type js"
else
OSX=