This file contains hidden or 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
Utility = function () { | |
return { | |
linkify: function (text) { | |
if (text) { | |
text = text.replace( | |
/((https?\:\/\/)|(www\.))(\S+)(\w{2,4})(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/gi, | |
function(url){ | |
var full_url = url; | |
if (!full_url.match('^https?:\/\/')) { | |
full_url = 'http://' + full_url; |
This file contains hidden or 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
def get_redirected_page(url) | |
uri = URI.parse(url) | |
if uri.scheme == "https" | |
http = Net::HTTP.new(uri.host, uri.port) | |
http.use_ssl = true | |
http.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
request = Net::HTTP::Get.new(uri.request_uri) | |
response = http.request(request) | |
response['location'] | |
else |
This file contains hidden or 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
# Rake task to launch multiple Resque workers in development/production with simple management included | |
require 'resque/tasks' # Require Resque tasks | |
namespace :workers do | |
# = $ rake workers:start | |
# | |
# Launch multiple Resque workers with the Rails environment loaded, | |
# so they have access to your models, etc. |
This file contains hidden or 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
# http://www.catalysoft.com/articles/StrikeAMatch.html | |
class Similarity | |
def initialize(str1, str2) | |
@str1 = str1 | |
@str2 = str2 | |
@set1 = build_character_pair(str1) | |
@set2 = build_character_pair(str2) | |
end |
This file contains hidden or 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
bundle config build.mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config | |
env ARCHFLAGS="-arch x86_64" |
This file contains hidden or 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
def extract_emails_to_array(txt) | |
reg = /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/i | |
txt.scan(reg).uniq | |
end | |
input = IO.readlines("in.txt") | |
output = File.new("mails.txt", "w+") | |
This file contains hidden or 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
config.action_mailer.delivery_method = :sendmail |
This file contains hidden or 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
<%= mark_required(@user, :email) %> | |
# module ApplicationHelper | |
# def mark_required(object, attribute) | |
# "*" if object.class.validators_on(attribute).map(&:class).include? ActiveModel::Validations::PresenceValidator | |
# end | |
# end | |
1. <%= form_for(@user) do |f| %> | |
2. <%= render "shared/error_messages", :target => @user %> |
This file contains hidden or 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
Twitter = function () { | |
// user credentials | |
var username, password, screen_name; | |
function make_basic_auth(user, password) { | |
var tok = user + ':' + password; | |
var hash = Base64.encode(tok); | |
return "Basic " + hash; | |
} | |
function switch_to_main() { |
This file contains hidden or 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
<html> | |
<head> | |
<script type="text/javascript" src="jquery-1.3.2.js" charset="utf-8"></script> | |
<script type="text/javascript" src="custom.js" charset="utf-8"></script> | |
<script type="text/javascript" src="base64.js" charset="utf-8"></script> | |
<script type="text/javascript" src="jquery.form.js" charset="utf-8"></script> | |
</head> | |
<body style="margin:0"> | |
<div id="main"> | |
<div id="loginForm" class="span-10 mLeft45"> |
NewerOlder