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
nickname = 'ihower' | |
1.upto(nickname.length-2) { |i| nickname[i] = '*' } | |
nickname # 'i****r' |
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
today = Date.today | |
birthday = Date.new(1986, 12,31) | |
overflow = ( today.month > birthday.month || | |
( today.month == birthday.month && today.day >= birthday.day ) | |
)? 0 : 1 | |
age = today.year.to_i - birthday.year.to_i - overflow |
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 nthweek( time ) | |
time.strftime("%U").to_i | |
end | |
def get_time_by_nthweek(i, year = Time.now.year) | |
first_day = Time.mktime(year,1,1) | |
first_day - first_day.wday.days + i*7.days | |
end | |
def next_nthweek(i, year = Time.now.year) |
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
(function($) { | |
$(document).ready(function() { | |
$('#bd').click(function(event) { | |
var target = $(event.target); | |
if (target.attr('rel') == 'external') { | |
if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) return true; | |
else { | |
var oWin = window.open(target.attr('href'), '_blank'); | |
if (oWin) { | |
if (oWin.focus) oWin.focus(); |
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
# Helper | |
def grid_row( cols ) | |
out = "" | |
cols.each do |col| | |
out << "<div class=\"grid_#{col[0]}\">#{col[1]}</div>" | |
end | |
return out | |
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
# HTML (from http://960.gs/ code example) | |
<div class="container_12"> | |
<div class="grid_7 prefix_1"> | |
<div class="grid_2 alpha"> | |
<p>...</p> | |
</div> | |
<div class="grid_3"> | |
<p>...</p> | |
</div> |
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
class ApplicationController < ActionController::Base | |
before_filter :log_session | |
def log_session | |
logger.info("Session debug: #{ (session.cgi.cookies['_registrano_session']).to_yaml }") | |
logger.info("Cookie get: #{session.instance_variable_get("@data").to_yaml}") | |
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
MD5 test | |
# ruby | |
require 'digest/md5' | |
puts Digest::MD5.hexdigest( File.read('foobar.png') ) | |
# php5 | |
echo md5( file_get_contents('foobar.png') ); |
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.geocities.com/calshing/dayofweek.htm | |
def get_week( year , month , day) | |
c = year.to_s[0, year.to_s.length-2 ].to_i | |
y = year.to_s[year.to_s.length-2,2] | |
a = (14-month)/12 | |
y = y.to_i - a | |
m = month + 12*a - 2 | |
y_div_4 = ( y == 0 )? 0 : (y/4) | |
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
SetEnv force-proxy-request-1.0 1 | |
SetEnv proxy-nokeepalive 1 | |
# Rewrite index to check for static | |
RewriteRule ^/$ /index.html [QSA] | |
# Rewrite to check for Rails cached page | |
RewriteRule ^([^.]+)$ $1.html [QSA] | |
# Redirect all non-static requests to cluster |
OlderNewer