This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Recursively remove .svn directories | |
# source => http://codesnippets.joyent.com/posts/show/735 | |
require 'find' | |
require 'fileutils' | |
Find.find('./') do |path| | |
if File.basename(path) == '.svn' | |
FileUtils.remove_dir(path, true) | |
Find.prune | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Minimal MaxLength validation on jQuery | |
// Expected markup : <textarea class="maxlen 250"></textarea> | |
jQuery("textarea.maxlen").live("keyup", function(event) { | |
var max = parseInt(this.className.match(/\d+/)); | |
var key = event.which; | |
if (max && (key >= 33 || key == 13)) { | |
if (this.value.length >= max) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C# version of :http://gist.github.com/59087 as an Extension method | |
public static String InWords(this DateTime from) | |
{ | |
double minutes = Math.Floor((DateTime.Now - from).TotalSeconds / 60); | |
if (minutes == 0) { return "less than a minute ago"; } | |
if (minutes == 1) { return "a minute ago"; } | |
if (minutes < 45) { return minutes + " minutes ago"; } | |
if (minutes < 90) { return "about 1 hour ago"; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The classic jQuery bookmark for injectin' jQuery on any page | |
javascript:(function() { var h = document.getElementsByTagName("head")[0]; var j = document.createElement("script"); j.type = "text/javascript"; j.src = "http://code.jquery.com/jquery.js"; h.appendChild(j);})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--// | |
idleFingers | |
Copyright (c) 2008 Fabio Zendhi Nagao <http://zend.lojcomm.com.br/> | |
Permission is hereby granted, free of charge, to any person | |
obtaining a copy of this software and associated documentation | |
files (the "Software"), to deal in the Software without | |
restriction, including without limitation the rights to use, | |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Some fun with EnumerateIt | |
class LocationType < EnumerateIt::Base | |
associate_values(:House => 1, :Apartment => 2, :Island => 3) | |
end | |
class Location < ActiveRecord::Base | |
has_enumeration_for :location_type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rm db/*.sqlite3 && rake db:create:all && rake db:migrate && rake db:seed && clear |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Cachebuster for C# | |
private const string LinkTag = "<link href=\"{0}\" type=\"text/css\" rel=\"stylesheet\" />"; | |
private const string JavascriptTag = "<script src=\"{0}\" type=\"text/javascript\"></script>"; | |
private String MapAsset(String url) | |
{ | |
FileInfo file = new FileInfo(Server.MapPath("~" + url)); | |
String format = file.Extension == ".js" ? JavascriptTag : LinkTag; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Xml; | |
namespace Test | |
{ | |
public class Table | |
{ | |
public IEnumerable<String> ColumnHeaders { get; private set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pt: | |
errors: | |
messages: | |
not_found: "não encontrado" | |
already_confirmed: "já foi confirmado" | |
not_locked: "não estava bloqueado" | |
devise: | |
failure: | |
unauthenticated: 'Você precisa entrar ou se registrar antes de continuar.' |
OlderNewer