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
require "rubygems" | |
require "bson" | |
require "mongoid" | |
require 'ap' | |
Mongoid.configure do |config| | |
name = "test" | |
host = "localhost" | |
config.allow_dynamic_fields = false |
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> | |
<html> | |
<head> | |
<%= yield :meta %> | |
</head> | |
<body> | |
<%- content_for :meta do %> | |
<%= render text: "Trying to return something" %> |
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
group :development, :test do | |
gem 'rspec-rails', '~> 2.9' # rails generate rspec:install | |
gem 'factory_girl_rails' | |
end | |
group :test do | |
gem 'spork-rails' # spork rspec --bootstrap | |
gem 'capybara' | |
gem 'launchy' | |
gem 'timecop' |
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
# -*- encoding : utf-8 -*- | |
# http://en.wikipedia.org/wiki/Partition_problem | |
# http://www.americanscientist.org/issues/id.3278,y.2002,no.3,content.true,page.1,css.print/issue.aspx | |
# http://www8.cs.umu.se/kurser/TDBAfl/VT06/algorithms/BOOK/BOOK2/NODE45.HTM | |
# http://ru.wikipedia.org/wiki/%D0%9B%D0%B8%D0%BD%D0%B5%D0%B9%D0%BD%D0%BE%D0%B5_%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5 | |
# http://www.rubyquiz.com/quiz65.html | |
require 'pp' | |
require './source_array' |
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
require 'faraday_middleware' | |
require 'hashie/mash' | |
# Public: GeoIP service using freegeoip.net | |
# | |
# See https://github.com/fiorix/freegeoip#readme | |
# | |
# Examples | |
# | |
# res = GeoipService.new.call '173.194.64.19' |
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
require 'net/http' | |
# WARNING do not use this; it works but is very limited | |
def resolve url | |
res = Net::HTTP.get_response URI(url) | |
if res.code == '301' then res['location'] | |
else url.to_s | |
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
run ->(e){ p=Hash[*e['QUERY_STRING'].split(/[&=]/)]; [200, {'Content-type'=>'text/html'}, ["Hello #{p['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
# returns [output string, err string, exit code] | |
def cmd(args, input = nil) | |
parent_read, child_write = IO.pipe | |
err_read, err_write = IO.pipe | |
child_read, parent_write = IO.pipe if input | |
pid = fork do | |
if input | |
parent_write.close | |
$stdin.reopen(child_read) |
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
def index | |
@find_text = params[:text] | |
@find_type = params[:type] | |
page = params[:page] || 1 | |
from = @find_from = (params[:from].blank?) ? (Time.now - 6.days).strftime("%d.%m.%Y") : params[:from] | |
till = @find_till = (params[:till].blank?) ? (Time.now + 1.day).strftime("%d.%m.%Y"): params[:till] | |
text = params[:text] | |
type = params[:type] || 1 | |
type = type.to_i |
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
(1.9.3@tops) master *% ~/projects/www/benj/tops $ | |
>rails_best_practices . | |
Source Codes: 100% |oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo| Time: 0:00:03 | |
./db/schema.rb:16 - always add db index (attachments => [attachmentable_id, attachmentable_type]) | |
./db/schema.rb:107 - always add db index (products => [manufacturer_id]) | |
./app/models/attachment_related/content_image.rb:31 - change Hash Syntax to 1.9 | |
./app/controllers/admin/images_controller.rb:39 - change Hash Syntax to 1.9 | |
./app/controllers/frontend_controller.rb:21 - change Hash Syntax to 1.9 | |
./app/decorators/product_decorator.rb:26 - change Hash Syntax to 1.9 | |
./config/application.rb:12 - change Hash Syntax to 1.9 |
OlderNewer