Skip to content

Instantly share code, notes, and snippets.

View kares's full-sized avatar
💤

Karol Bucek kares

💤
View GitHub Profile
@the8472
the8472 / minimal testing up
Created December 12, 2012 16:28
Rails startup performance tuning with jruby. Note that those settings are *not* for optimal steady state operation.
### ruby 1.9.3 + railsexpress patches + GC tuning + -march=native -O3
time ruby script/rails r 'Post.count'
real 0m1.008s
user 0m0.820s
sys 0m0.180s
### jruby 1.7.2-dev 2012-12-12 + java 64bit 1.8.0-ea-b67 hotspot 25.0-b11
@rwjblue
rwjblue / readme.md
Last active May 13, 2016 18:10
Guide to using drip with JRuby

#Overview drip is an awesome command line tool that can be used to dramatically lower perceived JVM startup time. It does this by preloading an entirely new JVM process\instance and allowing you to simply use the preloaded environment. This has extraordinary results with jruby.

We reduced time to run rake environment from 13 seconds to a mere 3.5 seconds. This is actually at or near MRI 1.9.3p327 (with falcon patch) speeds!

Adding a few addition jruby options will reduce startup time even further (down to 1.69 seconds).

#Install Drip Install drip if you haven't already (see https://github.com/flatland/drip)

@wnuqui
wnuqui / gist:4653064
Last active December 11, 2015 20:09
3 bare bone rails applications using 3 jruby application servers (all running in heroku cedar)
# JAVA_OPTS and Procfiles
JAVA_OPTS: -Djruby.memory.max=384m -Xmx384m -Xms256m -Xss512k -XX:+UseCompressedOops -XX:+PrintGCDetails
# puma backed app's Procfile
web: bundle exec rails server puma -p $PORT -e $RACK_ENV
# torquebox-lite backed app's Procfile
web: bin/torquebox-lite -b 0.0.0.0 -p $PORT --max-threads=8
@dabit
dabit / hash_table.rb
Last active May 16, 2023 16:57
Code example for my blogpost Hash lookup in Ruby, why is it so fast?
require 'benchmark'
#
# Code example for my blogpost
#
# Hash lookup in Ruby, why is it so fast?
#
#
# Struct used to store Hash Entries
@drogus
drogus / Rakefile.rb
Created July 26, 2013 10:49
This is the example contents of the Rakefile, which you would use to run active record tasks without using Rails. It assumes using the same directories as rails uses: `db/migrate`, `config/database.yml`.
require 'bundler/setup'
require 'active_record'
include ActiveRecord::Tasks
db_dir = File.expand_path('../db', __FILE__)
config_dir = File.expand_path('../config', __FILE__)
DatabaseTasks.env = ENV['ENV'] || 'development'
@madsheep
madsheep / kitten_mailer.rb
Created September 10, 2013 14:58
Any mailer inherited from this one will have random cat included as an attachment.
class KittenMailer < ActionMailer::Base
def mail *args
attachments['cat.jpeg'] = open("http://placekitten.com/#{rand(300)+300}/#{rand(300)+300}").read
super
end
end
@headius
headius / ffi_crypt.rb
Created September 19, 2013 16:17
Binding the libc 'crypt' function using FFI.
require 'ffi'
module Crypt
extend FFI::Library
ffi_lib 'c'
attach_function :crypt, [:string, :string], :string
end
p Crypt.crypt 'this is a string', 'this is the salt'
@furzeface
furzeface / GitHub Gist Basic Styles
Created December 12, 2013 19:13
GitHub Gists default CSS selectors and base styles.
.gist {
color: #000;
.render-container {
.render-viewer-error,
.render-viewer-fatal,
.octospinner {
display: none;
}
}
@michaelglass
michaelglass / alerts_and_confirms.rb
Last active September 24, 2019 10:15
test alerts & confirms in poltergeist & capybara webkit
module AlertConfirmer
class << self
def reject_confirm_from &block
handle_js_modal 'confirm', false, &block
end
def accept_confirm_from &block
handle_js_modal 'confirm', true, &block
end
@mattbrictson
mattbrictson / application.html.erb
Last active August 16, 2023 15:33
Simpler nested layouts in Rails using the parent_layout helper
<%= render("shared/navbar") %>
<div class="container">
<%= render("shared/alerts") %>
<%= render("shared/page_header") %>
<%= yield %>
<%= render("shared/footer") %>