Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/dumb-init /bin/sh
set -e
# Note above that we run dumb-init as PID 1 in order to reap zombie processes
# as well as forward signals to all processes in its session. Normally, sh
# wouldn't do either of these functions so we'd leak zombies as well as do
# unclean termination of all our sub-processes.
# Prevent core dumps
ulimit -c 0
@greendog
greendog / rspec_rails_cheetsheet.rb
Created January 11, 2017 08:12 — forked from them0nk/rspec_rails_cheetsheet.rb
Rspec Rails cheatsheet (include capybara matchers)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
# Russian. Updated 2014-04-01
ru:
admin:
js:
true: 'True'
false: 'False'
is_present: 'Не пустое'
is_blank: 'Пустое'
date: 'Дата ...'
unless Rails.env.production?
connection = ActiveRecord::Base.connection
connection.tables.each do |table|
connection.execute("TRUNCATE #{table}") unless table == "schema_migrations"
end
sql = File.read('db/import.sql')
statements = sql.split(/;$/)
statements.pop
@greendog
greendog / gist:5403564
Created April 17, 2013 11:32
Multilevel bootstrap menu
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid">
<a data-target=".nav-collapse" data-toggle="collapse" class="btn btn-navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a href="#" class="brand">Project name</a>
<div class="nav-collapse">
@greendog
greendog / active_admin_and_jquery_autocomplete.txt
Last active December 15, 2015 17:30
active_admin + jquery autocomplete
1. to Gemfile:
gem "rails3-jquery-autocomplete"
gem "jquery-ui-rails"
2. to active_admin.css.scss
@import "active_admin/mixins";
@import "active_admin/base";
@import "jquery.ui.all";
module LiquorTemplateLoader
def self.namespace_to_params(pack, namespace)
if namespace == :html
scope = pack.html_templates
externals = [ :site, :request ]
elsif namespace == :email
scope = pack.email_templates
externals = [ :site, :subscription ]
end
@greendog
greendog / liquid.rb
Created January 23, 2013 12:54
Create a Liquid Handler for Rails 3.1 Use: require 'action_view/template/handlers/liquid' ActionView::Template.register_template_handler :liquid, ActionView::Template::Handlers::Liquid
class ActionView::Template::Handlers::Liquid
def self.call(template)
"ActionView::Template::Handlers::Liquid.new(self).render(#{template.source.inspect}, local_assigns)"
end
def initialize(view)
@view = view
end
def render(template, local_assigns = {})
@greendog
greendog / liquid.rb
Created January 23, 2013 12:46 — forked from sgruhier/liquid.rb
class LiquidHandler
PROTECTED_ASSIGNS = %w( template_root response _session template_class action_name request_origin session template
_response url _request _cookies variables_added _flash params _headers request cookies
ignore_missing_templates flash _params logger before_filter_chain_aborted headers )
def self.call(template)
new.compile(template)
end
def compile(template)