Skip to content

Instantly share code, notes, and snippets.

View leifcr's full-sized avatar

Leif Ringstad leifcr

View GitHub Profile
@leifcr
leifcr / gist:9462906
Last active August 29, 2015 13:57 — forked from pahanix/gist:885671
# config/initializers/clear_dev_logs.rb
# This snippet simply clears your logs when they are too large.
# Large logs for development are usually something you don't want.
# Every time you run rails server or rails console it checks the size
# of your development logfile and truncates it.
if Rails.env.development?
MAX_LOG_SIZE = 1.megabytes
DEV_LOG_FILE = File.join(Rails.root, 'log', 'development.log')
# /etc/monit/conf.d/avialable/foo_delayed_job_production.conf
#
# Monit configuration for Delayed Job
#
# Delayed job for app foo running as deploy in environment production
#
# Service name: foo_production_delayed_job
#
check process foo_production_delayed_job
# Checking for a pidfile
@leifcr
leifcr / config.json
Last active August 29, 2015 14:15 — forked from anonymous/config.json
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "darken(#428bca, 6.5%)",
"@brand-success": "#5cb85c",
@leifcr
leifcr / will_paginate.rb
Created October 21, 2011 21:35 — forked from henrik/will_paginate.rb
Extends will_paginate to play well with Twitter's Bootstrap (http://twitter.github.com/bootstrap/). Suggested location: config/initializers/will_paginate.rb
# https://gist.github.com/1305042
module WillPaginate
module ActionView
def will_paginate(collection = nil, options = {})
options[:renderer] ||= BootstrapLinkRenderer
super.try :html_safe
end
class BootstrapLinkRenderer < LinkRenderer
# mongo_template.rb
# remove unneeded defaults
run "rm public/index.html"
run "rm public/images/rails.png"
run "rm public/javascripts/controls.js"
run "rm public/javascripts/dragdrop.js"
run "rm public/javascripts/effects.js"
run "rm public/javascripts/prototype.js"
@leifcr
leifcr / page.rb
Created December 19, 2011 09:52
Rails 3.1 Helper Issue in production mode with cache_classes=true
#model page.rb
class Page < ActiveRecord::Base
STATUSES = %w[new published]
end
@leifcr
leifcr / gist:2145998
Created March 21, 2012 10:21
maler-pris dig
----------------------------------------------
leif@gnomik:~$ dig @8.8.8.8 maler-pris.dk
; <<>> DiG 9.7.0-P1 <<>> @8.8.8.8 maler-pris.dk
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 59780
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
@leifcr
leifcr / quiet_assets.rb
Created December 11, 2012 18:07
Rails 3.2 compatible quiet assets
if Rails.env.development?
Rails.application.assets.logger = Logger.new('/dev/null')
Rails::Rack::Logger.class_eval do
def call_with_quiet_assets(env)
previous_level = Rails.logger.level
Rails.logger.level = Logger::ERROR if env['PATH_INFO'].index("/assets/") == 0
call_without_quiet_assets(env).tap do
Rails.logger.level = previous_level
end
end
@leifcr
leifcr / .irbrc
Last active December 13, 2015 16:58 — forked from patmcnally/.irbrc
irbrc with wirble, hirb and awesome_print + logging of activesupport requests...
# load libraries
require 'rubygems' rescue nil
alias q exit
class Object
def local_methods
(methods - Object.instance_methods).sort
end
end
@leifcr
leifcr / leifcr.zsh-theme
Created March 14, 2013 08:48
Oh-my-zsh theme based on "muse". Added green user@machine
#!/usr/bin/env zsh
#local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
setopt promptsubst
autoload -U add-zsh-hook
PROMPT_SUCCESS_COLOR=$FG[117]
PROMPT_FAILURE_COLOR=$FG[124]
PROMPT_VCS_INFO_COLOR=$FG[242]