Skip to content

Instantly share code, notes, and snippets.

View arturopie's full-sized avatar
:shipit:
shipping

Arturo Pie arturopie

:shipit:
shipping
View GitHub Profile
@arturopie
arturopie / domain-event-rules.md
Last active January 8, 2019 04:33
Domain Event Rules

Rules for building Domain Events

Rule #1: Naming is hard - really hard

A Domain Event is:

Something that has already happened, and therefore should be named in past tense It should be named in business language (Ubiquitous Language) Represents a state change Something that will never change (the record is written once and never edited afterwards)

@arturopie
arturopie / ec2_helper.rb
Created March 5, 2018 19:46 — forked from tom-butler/ec2_helper.rb
Get Running Instance ID
require 'aws-sdk'
# Return only a single running instance with the Name tag specified
class EC2Helper
def self.GetIdFromName(name)
instances = Array.new
# Filter the ec2 instances for name and state pending or running
ec2 = Aws::EC2::Resource.new(region: ENV['AWS_DEFAULT_REGION'])
ec2.instances({filters: [
posts = IndexQueryBuilder.query Post, with: filters do |query|
query.filter_field [:comments, :text], contains: :comment_text
query.order_by "view_count DESC"
end
conditions_strings = []
conditions_params = {}
unless filters[:comment_text].blank?
conditions_strings << "comments.text ILIKE :comment_text"
conditions_params[:comment_text] = "%#{filters[:comment_text]}%"
end
conditions = (conditions_params.empty? ? "" : [conditions_strings.join(" AND "), conditions_params])
@arturopie
arturopie / file_generator.rb
Created February 24, 2013 00:48
Random words generator
# First, install gem faker:
# $ gem install faker
# Usage:
# $ ruby file_generator.rb > file.in
require 'faker'
NUM_OF_WORDS = 1000
NUM_OF_WORDS.times do
@arturopie
arturopie / zeus-crash.txt
Created November 6, 2012 21:29
zeus server crash output
Starting Zeus server
[ready] [crashed] [running] [connecting] [waiting]
boot
└── default_bundle
├── development_environment
│  └── prerake
└── test_environment
├── test_unit
├── acceptance_test
└── rspec
@arturopie
arturopie / ruby_require_load_tree.rb
Created November 2, 2012 17:13
Print require/load tree
$require_level = []
alias :orig_require :require
def require(file)
puts "#{$require_level.join}#{file}"
$require_level << "-"
r = orig_require(file)
$require_level.pop
r
end
@arturopie
arturopie / remote_commands.rb
Created September 26, 2012 01:55
Using EventMachine to execute commands in several host at once
require 'eventmachine'
require 'colorize'
class RemoteCommands < EM::Connection
attr_reader :queue
def initialize(q)
@queue = q
cb = Proc.new do |msg|
@arturopie
arturopie / _rake
Created April 9, 2012 18:31
rake fast autocomplition
# rake autocompletion from:
_rake_does_task_list_need_generating () {
if [ ! -f .rake_tasks~ ]; then return 0;
else
accurate=$(stat -c=%y .rake_tasks~)
changed=$(stat -c=%y Rakefile)
return $(expr $accurate '>=' $changed)
fi
}
@arturopie
arturopie / 0-readme.md
Created March 8, 2012 03:39
ruby-1.9.3-p125 cumulative performance patch.

Patched ruby 1.9.3-p0 for 30% faster rails boot

What is?

This script installs a patched version of ruby 1.9.3-p0 with patches to make ruby-debug work again (#47) and boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84).

Huge thanks to funny-falcon for the performance patches.