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
# SOURCE: | |
# http://rubylearning.com/blog/2014/01/24/from-lousy-to-beautiful/ | |
module StatsApi | |
require 'json' | |
require 'httparty' | |
require 'active_support/core_ext/string' | |
require 'jsonpath' | |
## Reader: note that @error is raised so that we can easily handle that in our parent methods... |
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
# Activate the gem you are reporting the issue against. | |
gem 'activerecord', '4.0.0' | |
require 'active_record' | |
require 'minitest/autorun' | |
require 'logger' | |
# This connection will do for database-independent bug reports. | |
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') | |
ActiveRecord::Base.logger = Logger.new(STDOUT) |
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
package org.testfu.storm; | |
import backtype.storm.Config; | |
import backtype.storm.LocalCluster; | |
import backtype.storm.LocalDRPC; | |
import backtype.storm.StormSubmitter; | |
import backtype.storm.generated.StormTopology; | |
import backtype.storm.tuple.Fields; | |
import storm.trident.TridentState; | |
import storm.trident.TridentTopology; |
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
#!/bin/sh | |
# http://stackoverflow.com/questions/3878624/how-do-i-programmatically-determine-if-there-are-uncommited-changes | |
require_clean_work_tree () { | |
# Update the index | |
git update-index -q --ignore-submodules --refresh | |
err=0 | |
# Disallow unstaged changes in the working tree | |
if ! git diff-files --quiet --ignore-submodules --; then |
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
# MOTIVATION: As rails apps are growing, people are noticing the drawbacks | |
# of the ActiveRecord pattern. Several apps I have seen, and several | |
# developers I have spoken to are looking towards other patterns for object | |
# persistence. The major drawback with ActiveRecord is that the notion | |
# of the domain object is conflated with what it means to store/retrieve | |
# it in any given format (like sql, json, key/value, etc). | |
# | |
# This is an attempt to codify the Repository pattern in a way that would | |
# feel comfortable to beginner and seasoned Ruby developers alike. | |
# |
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 'dm-mapper' | |
require 'data_mapper/support/veritas/adapter/in_memory' | |
class Person | |
attr_reader :id, :name | |
def initialize(attributes) | |
@id, @name = attributes.values_at(:id, :name) | |
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
# file 'fruit_mapper.rb' | |
class FruitMapper < DataMapper::Mapper | |
map :id, Integer | |
map :name, String | |
map :taste, String | |
end | |
# file 'fruit_mapper_spec.rb' | |
require 'fruit_mapper' | |
describe FruitMapper do |
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
<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/maven-v4_0_0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>org.acme.test</groupId> | |
<artifactId>nodejs-dependency</artifactId> | |
<version>0.0.1-SNAPSHOT</version> | |
<name>nodejs-dependency</name> | |
<description>NodeJS Dependency Project - to be references in nodejs-test</description> | |
<packaging>jar</packaging> |
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
<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/maven-v4_0_0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>org.acme.test</groupId> | |
<artifactId>nodejs-test</artifactId> | |
<version>0.0.1-SNAPSHOT</version> | |
<name>nodejs-test</name> | |
<description>NodeJS Test Project</description> | |
<packaging>jar</packaging> |
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_relative '../../../spec/spec_helper_without_rails' | |
require_relative 'amazon_search_response_parser_crack_hashie' | |
response = OpenStruct.new(body: File.read('spec/fixtures/amazon_api_responses/search_response_multiple_items.xml')) | |
result = AmazonSearchResponseParser.new.parse(response) | |
tests_to_run = 100 | |
start = Time.now | |
tests_to_run.times { AmazonSearchResponseParser.new.parse(response) } | |
nokogiri = Time.now - start |