Skip to content

Instantly share code, notes, and snippets.

@mindhalt
mindhalt / rem-calibrate.css
Last active August 29, 2015 14:25 — forked from brianblakely/rem-calibrate.css
Simulate vw with rems
/* Android stock browser won't let you set font-size smaller than 8px unless you apply this. */
:root {
-webkit-text-size-adjust: none;
-moz-text-size-adjust: none;
-ms-text-size-adjust: none;
-o-text-size-adjust: none;
text-size-adjust: none;
}
class PagesController < ApplicationController
before_filter :login_required, :except => [ :show ]
# GET /pages
# GET /pages.xml
def index
@pages = Page.find(:all)
respond_to do |format|
format.html # index.html.erb
class ApplicationController < ActionController::Base
...
#Problem:
#In rails 3.0.1+ it is no longer possible to do this anymore;
# rescue_from ActionController::RoutingError, :with => :render_not_found
#
#The ActionController::RoutingError thrown is not caught by rescue_from.
#The alternative is to to set a catch-all route to catch all unmatched routes and send them to a method which renders an error
#As in http://techoctave.com/c7/posts/36-rails-3-0-rescue-from-routing-error-solution
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Railscasts 2</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
@mindhalt
mindhalt / controller.rb
Created July 5, 2013 14:38
Simple math captcha for Rails Fixed version of http://blog.trikeapps.com/2010/12/20/secure-form-with-math-captcha.html Tested on Rails 3.2.13 and Ruby 2.0.0 P.S. don't forget to include math_captcha.rb to included paths.
require 'math_captcha'
class CarsController < ApplicationController
# GET|POST /order
def order
@item = Item.find(params[:id])
if request.get?
@form = ModellessForm.new
@mindhalt
mindhalt / gist:5425217
Last active December 16, 2015 11:09 — forked from JoshMcKin/gist:801101
Nginx+Thin+SSL
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;
#place this in config/locales/translit.rb
# encoding: utf-8
# I18n transliteration delegates to Russian::Transliteration (we're unable
# to use common I18n transliteration tables with Russian)
#
# Правило транслитерации для I18n использует Russian::Transliteration
# (использовать обычный механизм и таблицу транслитерации I18n с
# русским языком не получится)