Skip to content

Instantly share code, notes, and snippets.

@phuesler
phuesler / timeout_benchmark.rb
Created April 23, 2014 16:04
Testing how big the overhead of ruby timeout is
require 'benchmark'
require 'timeout'
N = 10_000
def just_loop
N.times do |i|
i + 1
end
end
namespace :web do
desc "Custom task to disable web"
task :disable, :roles => :web, :except => {:no_release => true} do
require 'erb'
on_rollback {run "rm #{shared_path}/system/maintenance.html"}
template = File.read(File.join(File.dirname(__FILE__), "deploy", "templates", "maintenance.html.erb"))
result = ERB.new(template).result(binding)
put result, "#{shared_path}/system/maintenance.html", :mode => 0644
end
end
def save_profile
unless params[:user].blank?
if params[:user][:uploaded_picture].blank?
params[:user].delete(:uploaded_picture)
end
end
u = current_user
err_msg = nil
begin
module Sass::Script
module Functions
# substitue text in a string
# @params
# str the string to substitute text from
# reg the regexp given to sub
# rep the replacement text
def sub(str, reg, rep = '')
Sass::Script::String.new(str.to_s.sub(/#{reg.to_s}/, rep.to_s))
end
<VirtualHost *:80>
ServerName cootweet_p.local
DocumentRoot "/Users/joe/work/cootweet/public"
RailsEnv production
RailsAllowModRewrite off
ExpiresActive on
<directory "/Users/joe/work/cootweet/public">
Options -Indexes
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
server {
listen 80;
server_name localhost;
root /home/kafka/apps/cootweet/public; # <--- be sure to point to 'public'!
passenger_enabled on;
location ~* \.(ico|css|js|gif|jp?g|png)(\?[0-9]+)?$ {
expires max;
break;
}
ExpiresActive on
<FilesMatch "\.(js|css|gif|png|jpg)$">
ExpiresDefault "access plus 2 year"
</FilesMatch>
gzip on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
<directory "/Users/joe/work/cootweet/public">
Options -Indexes
Order allow,deny
Allow from all
AddOutputFilterbyType DEFLATE text/plain text/html text/css application/javascript text/xml application/xml application/xml+rss text/javascript
</directory>