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
| a.rb | |
| require 'rubygems' | |
| require 'mysql' | |
| loop do | |
| # Datum.transaction do | |
| connection = Mysql.new('localhost', 'root', 'password', 'ara_example') | |
| connection.autocommit false |
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_mock = mock('Net::HTTPResponse') | |
| http_mock.stubs(:code => '200', :body => 'response body', :message => 'response message') | |
| Net::HTTP::Post.any_instance.expects(:body=).with("post body").once | |
| Net::HTTP.any_instance.expects(:request).with(anything).once.returns(http_mock) |
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
| module Ohm | |
| class Model | |
| def self.zset(name, model = nil) | |
| attr_zset_reader(name, model) | |
| collections << name unless collections.include?(name) | |
| end | |
| def self.attr_zset_reader(name, model) | |
| define_method(name) do |
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
| <?xml version="1.0" encoding="UTF-8"?> | |
| <project xmlns="http://maven.apache.org/POM/4.0.0" | |
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
| <modelVersion>4.0.0</modelVersion> | |
| <groupId>template</groupId> | |
| <artifactId>template</artifactId> | |
| <version>1.0</version> |
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
| #!/usr/bin/env ruby | |
| require 'rubygems' | |
| require 'net/http' | |
| require 'uri' | |
| class SimpleCometClient | |
| def initialize() | |
| @uri = URI.parse('http://www.localhash.com/publishers/myspace/stream') | |
| @http = Net::HTTP.new(@uri.host, @uri.port) |
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 foo(first, second = first, third = second.size) | |
| [first, second, third] | |
| end | |
| puts foo("hello") |
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
| create trigger activity_duplicate_check before insert on activities | |
| for each row begin | |
| set @activity_id=new.activity_id; | |
| set @poll_result_id=new.poll_result_id; | |
| set @created_at=new.created_at; | |
| set @data_collector_id=new.data_collector_id; | |
| begin | |
| declare found_ids int default 0; | |
| declare found_created_at datetime default 0; |
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
| public Set<OutboundTask> add(LinkedHashSet<T> itemsToFilter) { | |
| LinkedHashMultimap<Stream<T>, T> filteredItems = Multimaps.newLinkedHashMultimap(); | |
| Set<OutboundTask> outboundTasks = Sets.newHashSet(); | |
| for (T filterable : itemsToFilter) { | |
| filterAction(filteredItems, filterable); | |
| filterActor(filteredItems, filterable); | |
| filterTag(filteredItems, filterable); | |
| filterTo(filteredItems, filterable); | |
| filterRegarding(filteredItems, filterable); |
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 ActiveRecord::ConnectionAdapters::MysqlAdapter | |
| def create_partitioned_table(table_name, &block) | |
| partition_sql = <<-sql | |
| ENGINE=InnoDB AUTO_INCREMENT=610925 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci | |
| partition by range (to_days(created_at)) | |
| ( | |
| partition p_0 values LESS THAN (to_days('2000-01-01')), | |
| sql | |
| partitions = (-4..4).collect do |i| |
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 LRUMemoryStore < ActiveSupport::Cache::Store | |
| def initialize(max_size = 1000) | |
| @max_size = max_size | |
| @data = {} | |
| @lru = [] | |
| end | |
| def read(name, options = nil) | |
| super |