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
x^0 -> 1 0 0 | |
x^1 -> 0 1 0 | |
x^2 -> 0 0 1 | |
x^3 -> 2 0 1 | |
x^4 -> 2 2 1 | |
x^5 -> 2 2 0 | |
x^6 -> 0 2 2 | |
x^7 -> 1 0 1 | |
x^8 -> 2 1 1 | |
x^9 -> 2 2 2 |
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
DELETE FROM traffics WHERE created_at < (CURDATE()-30) | |
DELETE FROM traffics WHERE created_at < DATE_SUB(NOW(), INTERVAL 1 MONTH) | |
DELETE FROM traffics WHERE created_at < '2010-01-01 00:00:00' | |
nothing works :| |
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
AllCops: | |
Exclude: | |
- config/**/* | |
- db/**/* | |
Metrics/LineLength: | |
Description: 'Limit lines to 120 characters.' | |
Max: 120 | |
Metrics/CyclomaticComplexity: |
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 compare_to(version) | |
reject_fields = ["_id", "updated_at", "version"] | |
diff_array = self.versions[version-1].attributes.to_hash.to_a - self.attributes.to_hash.to_a | |
diff_array.delete_if {|f| reject_fields.include?(f.first) } | |
Hash[diff_array] | |
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
scope :case_insensitive_email, lambda { |email| where("email ILIKE ?", email) } | |
request parameters: {"email"=>"foo\\"} | |
PGError: ERROR: LIKE pattern must not end with escape character | |
: SELECT "users".* FROM "users" WHERE (email ILIKE 'foo\') LIMIT 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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'resque' | |
HOST = ENV['host'] ? ENV['host'] : '127.0.0.1' | |
PORT = ENV['port'] ? ENV['port'] : '6379' | |
Resque.redis = "#{HOST}:#{PORT}" |
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 | |
require 'rubygems' | |
require 'resque' | |
HOST = ENV['host'] ? ENV['host'] : '127.0.0.1' | |
PORT = ENV['port'] ? ENV['port'] : '6379' | |
Resque.redis = "#{HOST}:#{PORT}" |
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 Api::V1::OpenRateController < ActionController::Metal | |
include ActionController::DataStreaming | |
def show | |
tracking_gif = "GIF89a\x03\x00\x02\x00\x80\x00\x00\xC0\xC0\xC0\x00\x00\x00!\xF9\x04\x01\x00\x00\x00\x00,\x00\x00\x00\x00\x03\x00\x02\x00\x00\x02\x02\x84_\x00;".freeze | |
send_data tracking_gif | |
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
cd tmp/x86_64-darwin11.3.0/ruby_mapnik/1.9.3 | |
make | |
compiling ../../../../ext/ruby_mapnik/_mapnik_feature.rb.cpp | |
cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++ | |
cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++ | |
In file included from /Users/ben/.rvm/gems/ruby-1.9.3-p194@mapnik/gems/rice-1.4.3/ruby/lib/include/rice/detail/../to_from_ruby.hpp:5, | |
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@mapnik/gems/rice-1.4.3/ruby/lib/include/rice/detail/Auto_Function_Wrapper.ipp:12, | |
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@mapnik/gems/rice-1.4.3/ruby/lib/include/rice/detail/Auto_Function_Wrapper.hpp:826, | |
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@mapnik/gems/rice-1.4.3/ruby/lib/include/rice/detail/wrap_function.ipp:10, | |
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@mapnik/gems/rice-1.4.3/ruby/lib/include/rice/detail/wrap_function.hpp:338, |
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
cd tmp/x86_64-darwin11.3.0/ruby_mapnik/1.9.3 | |
make | |
compiling ../../../../ext/ruby_mapnik/_mapnik_feature.rb.cpp | |
cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++ | |
cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++ | |
In file included from /Users/ben/.rvm/gems/ruby-1.9.3-p194@mapnik/gems/rice-1.4.3/ruby/lib/include/rice/detail/../to_from_ruby.hpp:5, | |
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@mapnik/gems/rice-1.4.3/ruby/lib/include/rice/detail/Auto_Function_Wrapper.ipp:12, | |
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@mapnik/gems/rice-1.4.3/ruby/lib/include/rice/detail/Auto_Function_Wrapper.hpp:826, | |
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@mapnik/gems/rice-1.4.3/ruby/lib/include/rice/detail/wrap_function.ipp:10, | |
from /Users/ben/.rvm/gems/ruby-1.9.3-p194@mapnik/gems/rice-1.4.3/ruby/lib/include/rice/detail/wrap_function.hpp:338, |