Skip to content

Instantly share code, notes, and snippets.

View wbotelhos's full-sized avatar
💭
I'm not my code.

Washington Botelho wbotelhos

💭
I'm not my code.
View GitHub Profile
@marugoshi
marugoshi / spork.rake
Created March 14, 2011 15:15
Start, stop, restart spork rake task
namespace :spork do
desc "start spork in background"
task :start do
sh %{spork &}
end
desc "stop spork"
task :stop do
Process.kill(:TERM, `ps -ef | grep spork | grep -v grep | awk '{ print $2 }'`.to_i)
end
@jboesch
jboesch / $.fn.outerHTML.js
Created March 27, 2011 07:11
$.fn.outerHTML method
/*
* Full example here: http://jsfiddle.net/jboesch26/3SKsL/1/
*/
$.fn.outerHTML = function(){
// IE, Chrome & Safari will comply with the non-standard outerHTML, all others (FF) will have a fall-back for cloning
return (!this.length) ? this : (this[0].outerHTML || (
function(el){
var div = document.createElement('div');
@mateusg
mateusg / pt-BR.yml
Last active August 14, 2016 13:42
pt-BR translations for Ruby on Rails
# encoding: UTF-8
# pt-BR translations for Ruby on Rails
"pt-BR":
date:
abbr_day_names:
- Dom
- Seg
- Ter
- Qua
- Qui
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="utf-8">
<title>Page Title</title>
<style type="text/css" media="screen">
.selected {
background: blue;
}
</style>
@bmarini
bmarini / default.vcl.pl
Created June 30, 2011 18:01
A good varnish config for a Rails app
# https://www.varnish-cache.org/docs/2.1/tutorial/vcl.html
# https://www.varnish-cache.org/trac/wiki/VCLExamples
# Summary
# 1. Varnish will poll the backend at /health_check to make sure it is
# healthy. If the backend goes down, varnish will server stale content
# from the cache for up to 1 hour.
# 2. Varnish will pass X-Forwarded-For headers through to the backend
# 3. Varnish will remove cookies from urls that match static content file
# extensions (jpg, gif, ...)
@lucascs
lucascs / CustomJSONSerialization.java
Created July 4, 2011 18:14
overriding json serialization from VRaptor to cope with dates
import com.thoughtworks.xstream.converters.basic.DateConverter;
@Component
public class CustomJSONSerialization extends XStreamJSONSerialization {
public CustomJSONSerialization(HttpServletResponse response,TypeNameExtractor extractor, ProxyInitializer initializer) {
super(response, extractor, initializer);
}
@Override
public XStream getXStream() {
@rponte
rponte / c3p0_configuration_pt-BR.properties
Last active August 4, 2022 23:04
c3p0 configuration in portuguese
http://stackoverflow.com/questions/4726512/recover-hibernate-connection
--
http://www.guj.com.br/java/116296-finalizar-conexoes---trabalhando-com-hibernatejpac3p0mysql
### *****************************
### **** Propriedades do C3P0 ***
### *****************************

Validations

Data integrity is an underrated part of proper application architecture. Many of the bugs in production systems are triggered by missing or malformed user data. If a user can possibly screw it up or screw with it, they will. Validations in the model can help!

On Syntax

Before we begin, let's talk about syntax. There are two primary syntaxes for writing validations in Rails 3:

validates_presence_of :price
@ChristianPeters
ChristianPeters / css_splitter.rake
Created August 8, 2011 10:22
Split CSS files so that there are no more than a given number of selectors in one style sheet. This is a tool to cope with Internet Explorer's limitation of max. 4095 selectors per stylesheet.
require 'rake'
require 'css_splitter'
desc 'split css files'
namespace :css do
task :split do
infile = ENV['infile'] || raise("missing infile")
outdir = ENV['outdir'] || File.dirname(infile)
max_selectors = ENV['max_selectors'] || 4095
@nuxlli
nuxlli / sublime_text_2_useful_shortcuts.md
Created September 9, 2011 18:51 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 - Useful Shortcuts

Tested in Mac OS X: super == command

Open/Goto


  • super+t: go to file
  • super+ctrl+p: go to project
  • super+r: go to methods