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
module Config | |
def self.included(klass) | |
klass.class_eval do | |
extend ClassMethods | |
include InstanceMethods | |
# block optional arguments example | |
define_double_method :cookie_key do |*args, &block| | |
name = args.shift |
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
select | |
concat_ws('_', object_type, object_subtype ) as type, | |
count(distinct complaints.object_owner_id) as cnt | |
from | |
complaints, | |
( select | |
object_id | |
from | |
complaints | |
where |
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
module RoutingFilter | |
class OldSiteRewrite < Filter | |
def around_recognize(path, env, &block) | |
additional_params = {} | |
if path =~ /^\/?([\w_-]+)\/?$/ && not_reserved($1) | |
path.replace "/categories/#{$1}" | |
elsif path =~ /^\/?([\w_-]+)\/([\w_-]+)\/?$/ && not_reserved($1) | |
path.replace "/reviews/#{$2}" | |
additional_params[:category] = $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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="ru-RU" | |
xmlns:og="http://opengraphprotocol.org/schema/" | |
xmlns:fb="http://www.facebook.com/2008/fbml"> | |
<head> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script> | |
</head> |
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
#!/usr/bin/env ruby | |
def to_time(h, m) | |
day, month, year = Time.now.to_a[3..5] | |
Time.mktime(year, month, day, h.to_i > 23 ? 0 : h, m).to_i | |
end | |
summ = 0 | |
Dir['*.txt'].each do |file_name| |
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
token = "DQAAAJMAAAD6eA_yqsc...KsqsmQ3SmntxMtAaWg9jO_OJvJNCXkfhBtfp" | |
ga = Gattica.new( | |
:token => token, | |
:headers => {'Authorization' => "GoogleLogin auth=#{token}"}, | |
:profile_id = 4689690 | |
) | |
res = ga.get( | |
:start_date => '2010-05-18', |
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
%% index comments | |
handle(HD, get, {comments}, Req) -> | |
[CommentableId, CommentableType] = commentable_params(Req), | |
Result = case ut:all_defined([CommentableType, CommentableId]) of | |
true -> | |
Key = {CommentableType, CommentableId}, | |
case cache:get(commentable_cache, Key) of |
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
$.extend(obj, (function(){ | |
function private_function(){...} | |
function private_function2(){...} | |
return { | |
public_function: function() {...}, | |
public_function2: function() {...} | |
} |
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
= menu :class => "navigation" do |m| | |
- if logged_in? | |
- m.item t("menu.my_articles"), workspace_path | |
- m.item t("menu.events"), events_path | |
- m.spacer | |
- if current_user.accepted? | |
- m.item t("menu.articles"), articles_path, /articles$/ | |
- m.item t("menu.users"), users_path | |
- m.spacer | |
- m.item t("menu.documents"), publications_path(:filter => 'documents') |
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
// Example: | |
// | |
// Posts = new Resource({url: 'http://localhost:3000/posts', model: 'post'}); | |
// | |
// Posts.create({ | |
// title: 'hey!', | |
// body: 'post!' | |
// }).send({ | |
// success: function(){ alert('!') } | |
// }); |