Skip to content

Instantly share code, notes, and snippets.

@janv
janv / Assetfile.rb
Created January 14, 2013 10:26 — forked from jondot/Assetfile
require 'rake-pipeline-web-filters'
output "public"
class Rake::Pipeline::DSL::PipelineDSL
def production?
ENV['RAKEP_MODE'] == 'production'
end
end
@janv
janv / nginx_error_rate.py
Created February 16, 2012 11:21 — forked from eykd/nginx_error_rate.py
Munin plugin for displaying error rates from Nginx
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""nginx_error_rate -- Munin plugin to report the error rate in an access log.
The access log defaults to `/var/log/nginx/access.log`. This may be
customized with the following stanza in your munin plugin conf:
[nginx_error_rate]
env.access_log /path/to/access.log
"""
@janv
janv / application.rb
Created February 15, 2012 13:30 — forked from mcmire/application.rb
Integrating the Logging framework into your Rails 3 app
#-----------------------------------------------------------------------------------------------
# config/application.rb
#-----------------------------------------------------------------------------------------------
require File.expand_path('../boot', __FILE__)
require 'rails/all'
Bundler.require(:default, Rails.env) if defined?(Bundler)
# Bring in the Railtie that will set Rails' various logger variables to
# instances of Logging::Logger instead of Rails' built-in ActiveSupport::BufferedLogger.
@janv
janv / spec_helper.rb
Created January 21, 2012 18:36 — forked from yitzhakbg/spec_helper.rb
My spec_helper.rb
require 'rubygems'
require 'spork'
def start_simplecov
require 'simplecov'
SimpleCov.start 'rails' unless ENV["SKIP_COV"]
end
def spork?
defined?(Spork) && Spork.using_spork?
@janv
janv / have_content_type.rb
Created January 20, 2012 15:47 — forked from jcf/MIT License
RSpec matcher for parsing `response.headers['Content-Type']`
RSpec::Matchers.define :have_content_type do |content_type|
CONTENT_HEADER_MATCHER = /^(.*?)(?:; charset=(.*))?$/
chain :with_charset do |charset|
@charset = charset
end
match do |response|
_, content, charset = *content_type_header.match(CONTENT_HEADER_MATCHER).to_a
@janv
janv / .irbrc
Created November 16, 2011 15:36 — forked from adamcrown/.irbrc
My Bundler proof .irbrc file including wirble, awesome_print, hirb, console logging and route helpers
require 'rubygems' unless defined? Gem # rubygems is only needed in 1.8
def unbundled_require(gem)
loaded = false
if defined?(::Bundler)
Gem.path.each do |gems_path|
gem_path = Dir.glob("#{gems_path}/gems/#{gem}*").last
@janv
janv / gist:703924
Created November 17, 2010 19:41 — forked from tisba/gist:703646
#!/usr/bin/env ruby
require "#{ENV['TM_SUPPORT_PATH']}/lib/exit_codes.rb"
require "#{ENV['TM_SUPPORT_PATH']}/lib/ui.rb"
require "rubygems"
require 'active_support/inflector'
current_word = ENV['TM_CURRENT_WORD'] || ""
def gem_exists?(name)
@janv
janv / add_attachment_data_to_wrapper.rb
Created November 2, 2009 16:30 — forked from Traz/add_attachment_data_to_wrapper.rb
Small tips for building a polymorphic usage of Paperclip, with video to flv, video thumbnail, mp3 tag extraction, zip file listing processors.
class AddAttachmentsDataToWrapper < ActiveRecord::Migration
def self.up
add_column :wrappers, :data_file_name, :string
add_column :wrappers, :data_content_type, :string
add_column :wrappers, :data_file_size, :integer
add_column :wrappers, :data_updated_at, :datetime
end
def self.down
remove_column :wrappers, :data_file_name
@janv
janv / gist:184586
Created September 10, 2009 14:44 — forked from clemens/gist:2843
Permalinks mit Umlauten
ActionController::Base.logger.info "[Base] Loading config/initializers/" + File.basename(__FILE__)
class String
def to_permalink
text = self.dup
replacements = {
# replacement special character(s) to be replaced
"A" => [ "À", "Á", "Â", "Ã", "Å"],
"Ae" => [ "Ä", "Æ" ],
"C" => [ "Ç" ],