Skip to content

Instantly share code, notes, and snippets.

@ka8725
ka8725 / states_matcher.rb
Created December 13, 2013 12:23
Custom matcher for Rspec to test state_machine status flow
# This custom matcher can be used to test state machine
#
# Examples
#
# it { should have_event(:status, :event_name, [:state1, :state2] => [:state3, :state4]) }
# it { should have_event(:status, :event_name, {
# :state1 => :state3,
# :state1 => :state4,
# :state3 => :state3,
# :state2 => :state4
@skwp
skwp / dynamic_method_spec.rb
Created December 7, 2013 00:44
Fail your build for user-defined style rules.
require 'spec/support/grep_matcher'
describe do
disallow_presence_of pattern: "send(.*#",
location: "app/",
description: "Do not use dynamic method invocations",
failure: "Please change dynamic method call to something more sane."
end
@mattetti
mattetti / rails_json_session.rb
Last active September 23, 2020 07:04
This is a monkey patch to change Rails 4's default session/signed cookie serializer from Marshal to JSON for security and compatibility reasons. Note that this is a hack, a pretty terrible one and you should only use it if you know what you're doing. Also, I only wrote this patch for my own personal use, so don't be surprised if it doesn't work …
# Hack to change the Rails cookie serializer from Marshal to JSON and therefore allow the session
# to be shared between different languages but also avoid that someone knowing the
# cookie secret key could execute arbitrary code on the server by unmarshalling
# modified Ruby code added to the session/permanent cookie.
#
# Note that all users will beed to login again since both the remember me cookie and the session cookies
# won't be valid. Note also that the remember me cookie is tested multiple times per request even when it fails.
# for performance reasons you might want to delete it if these extra cycles are too costly for you.
#
# Rails 4 (not tested on Rails 3).
@bodokaiser
bodokaiser / README.md
Last active February 8, 2022 19:44
Guide How-To use Device Tree Overlays on Archlinux.

Device Tree Overlays on Archlinux

Dependencies

base-devel

You require a working archlinuxarm operarting system and the development tools:

$ pacman -S base-devel
@rubiii
rubiii / how_it_works.md
Created December 2, 2012 11:14
MacVim-Formatter for RSpec
$ rspec --format MacVimFormatter --color spec
@mjtko
mjtko / howto.md
Created November 2, 2012 18:56 — forked from goosetav/howto.md
prevent ttf fonts while running poltergeist

RE: teampoltergeist/poltergeist#44

Use Rack::SimpleEndpoint to prevent Poltergeist/PhantomJS from crashing on TTF fonts.

Create config/initializers/middleware-deny-ttf-to-phantomjs-under-test.rb:

if Rails.env.test?
  require 'rack/contrib/simple_endpoint'
 Rails.application.config.middleware.insert_after Rack::Runtime, Rack::SimpleEndpoint, /\.ttf$/ do |req, res|
@goosetav
goosetav / howto.md
Created November 1, 2012 21:01
prevent ttf fonts while running poltergeist

RE: teampoltergeist/poltergeist#44

Use Rack::SimpleEndpoint to prevent Poltergeist/PhantomJS from crashing on TTF fonts.

In config/environments/test.rb, add

require 'rack/contrib/simple_endpoint'
config.middleware.insert_after Rack::Runtime, Rack::SimpleEndpoint, /\.ttf$/ do |req, res, match|
  res.status = '403'

"I will not serve TTF fonts in test mode."

@msluyter
msluyter / graphite.md
Created September 17, 2012 22:38 — forked from diver-in-sky/graphite.md
Installing Graphite on OS X Mountain Lion -- note, did not work for me!

Install Python 2.7.3 (if needed)

brew install python

Install cairo & py2cairo

brew install cairo
brew install py2cairo
@mikhailov
mikhailov / 0. nginx_setup.sh
Last active April 2, 2024 14:57
NGINX+SPDY with Unicorn. True Zero-Downtime unless migrations. Best practices.
# Nginx+Unicorn best-practices congifuration guide. Heartbleed fixed.
# We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies.
# Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module
#
# Deployment structure
#
# SERVER:
# /etc/init.d/nginx (1. nginx)
# /home/app/public_html/app_production/current (Capistrano directory)
#
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 3, 2024 19:09
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname