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
# blog post: http://blog.slashpoundbang.com/post/12694519460/email-validation-in-rails-3-or-active-model-without | |
# http://my.rails-royce.org/2010/07/21/email-validation-in-ruby-on-rails-without-regexp/ | |
class EmailValidator < ActiveModel::EachValidator | |
# Domain must be present and have two or more parts. | |
def validate_each(record, attribute, value) | |
address = Mail::Address.new value | |
record.errors[attribute] << (options[:message] || 'is invalid') unless (address.address == value && address.domain && address.__send__(:tree).domain.dot_atom_text.elements.size > 1 rescue false) | |
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
# blog post: http://blog.slashpoundbang.com/post/12695434343/how-to-safely-create-friendly-from-addresses-including | |
require 'mail' | |
# You already have +name+ and +email+ from the contact form. | |
address = Mail::Address.new email # [email protected] | |
address.display_name = name # John Doe | |
# Set the From or Reply-To header to the following: | |
address.format # John Doe <[email protected]> |
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
// Assumes you are using <html> conditional classes as described here: | |
// http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ | |
.lt-ie7 { | |
// blockquote small:before{content:'\2014 \00A0';} | |
blockquote small:before{content:"";} | |
// [class*="span"]{display:inline;float:left;margin-left:20px;} | |
.span1{display:inline;float:left;margin-left:20px;} | |
.span2{display:inline;float:left;margin-left:20px;} | |
.span3{display:inline;float:left;margin-left:20px;} | |
.span4{display:inline;float:left;margin-left:20px;} |
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
# blog post: http://blog.slashpoundbang.com/post/12938588984/google-refine-fingerprint-clustering-algorithm-in-ruby | |
# coding: utf-8 | |
require 'unicode_utils/downcase' | |
class String | |
# Normalize spaces and fingerprint. | |
# http://code.google.com/p/google-refine/wiki/ClusteringInDepth | |
# http://code.google.com/p/google-refine/source/browse/trunk/main/src/com/google/refine/clustering/binning/FingerprintKeyer.java | |
def fingerprint |
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
# blog post: http://blog.slashpoundbang.com/post/12938588984/remove-all-accents-and-diacritics-from-string-in-ruby | |
# coding: utf-8 | |
string.tr( | |
"ÀÁÂÃÄÅàáâãäåĀāĂ㥹ÇçĆćĈĉĊċČčÐðĎďĐđÈÉÊËèéêëĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħÌÍÎÏìíîïĨĩĪīĬĭĮįİıĴĵĶķĸĹĺĻļĽľĿŀŁłÑñŃńŅņŇňʼnŊŋÒÓÔÕÖØòóôõöøŌōŎŏŐőŔŕŖŗŘřŚśŜŝŞşŠšſŢţŤťŦŧÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųŴŵÝýÿŶŷŸŹźŻżŽž", | |
"AAAAAAaaaaaaAaAaAaCcCcCcCcCcDdDdDdEEEEeeeeEeEeEeEeEeGgGgGgGgHhHhIIIIiiiiIiIiIiIiIiJjKkkLlLlLlLlLlNnNnNnNnnNnOOOOOOooooooOoOoOoRrRrRrSsSsSsSssTtTtTtUUUUuuuuUuUuUuUuUuUuWwYyyYyYZzZzZz") |
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
// blog post: http://blog.slashpoundbang.com/post/15096433153/css3-scss-mixins | |
// Mixins ---------------------------------------------------------------------- | |
// http://css3please.com/ | |
@mixin background-rgba($red, $green, $blue, $opacity, $rgba) { | |
background-color: transparent; | |
background-color: rgba($red, $green, $blue, $opacity); | |
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$rgba}',endColorstr='#{$rgba}'); | |
zoom: 1; | |
} |
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
diff --git a/java/Makefile b/java/Makefile | |
index a4e8ba6..bf627ef 100644 | |
--- a/java/Makefile | |
+++ b/java/Makefile | |
@@ -27,8 +27,8 @@ else | |
endif | |
# | |
-export GCJFLAGS+= --encoding=UTF-8 --classpath="$(LIBGCJ):$(JAVALIBPATH):." | |
-export GCJHFLAGS+= --classpath="$(LIBGCJ):$(JAVALIBPATH):." |
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
<?php | |
/** | |
* @file | |
* Implements a Solr proxy. | |
* | |
* Currently requires json_decode which is bundled with PHP >= 5.2.0. | |
* | |
* You must download the SolrPhpClient and store it in the same directory as this file. | |
* |
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
class Wiki | |
def self.parse(lang, page) | |
begin | |
json = Yajl::Parser.parse open("http://#{lang}.wikipedia.org/w/api.php?maxlag=5&redirects=1&format=json&disablepp=1&prop=text%7Cdisplaytitle%7Crevid&action=parse§ion=0&page=#{CGI.escape(page)}").read | |
doc = Nokogiri::HTML(json['parse']['text']['*']) | |
# article message boxes | |
doc.css('.ambox').remove | |
doc.css('.bandeau').remove | |
doc.css('.bandeau-portail').remove |
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
# blog post: | |
require 'scraperwiki' | |
require 'epoxy' | |
require 'sql_parser' # @todo Gem can't parse strings with escaped single quotes | |
require 'mongo' | |
module ScraperWiki | |
class << self | |
def dumpMessage(hash) |