Skip to content

Instantly share code, notes, and snippets.

@SFEley
SFEley / gist:1054553
Created June 29, 2011 18:43 — forked from andrzejsliwa/gist:778535
list all available cucumber steps - (rake cucumber:steps)
# From https://gist.github.com/778535
# In turn based on http://www.natontesting.com/2010/01/11/updated-script-to-list-all-cucumber-step-definitions/
desc "List all available steps"
task :steps do
require 'hirb'
extend Hirb::Console
features_dir = "features"
step_candidates = Dir.glob(File.join(features_dir,'**/*.rb'))
# Follow all the gem requires, and identify which files have steps in them
@SFEley
SFEley / LambdaHandler.java
Created October 22, 2018 18:42
LambdaHandler.java
import java.util.List;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.nio.file.Paths;
import com.amazonaws.services.lambda.runtime.RequestStreamHandler;
import com.amazonaws.services.lambda.runtime.Context;
@SFEley
SFEley / gist:468520d54e0761c15783ec5fc2bd286d
Created October 22, 2018 18:25
AWS Lambda error - Java8 runtime, JRuby 9.2.1.0-SNAPSHOT
START RequestId: caa0d7b1-d626-11e8-8cd7-4be3c49bb13e Version: $LATEST
Could not load platform constants for OpenFlags: java.lang.RuntimeException
java.lang.RuntimeException: Could not load platform constants for OpenFlags
at jnr.constants.platform.ConstantResolver.getConstants(ConstantResolver.java:227)
at jnr.constants.platform.ConstantResolver.lookupAndCacheConstant(ConstantResolver.java:128)
at jnr.constants.platform.ConstantResolver.getConstant(ConstantResolver.java:116)
at jnr.constants.platform.ConstantResolver.longValue(ConstantResolver.java:179)
at jnr.constants.platform.OpenFlags.intValue(OpenFlags.java:31)
at org.jruby.RubyFile.createFileClass(RubyFile.java:135)
at org.jruby.Ruby.initCore(Ruby.java:1547)
@SFEley
SFEley / gist:7c3ba207cda253a953bc46e029503200
Created October 22, 2018 16:20
AWS Lambda error - Java8 runtime, JRuby 9.2.0.0
START RequestId: 58cbe585-d3e1-11e8-a5a7-efc54ba73b45 Version: $LATEST
Could not load platform constants for OpenFlags: java.lang.RuntimeException
java.lang.RuntimeException: Could not load platform constants for OpenFlags
at jnr.constants.platform.ConstantResolver.getConstants(ConstantResolver.java:227)
at jnr.constants.platform.ConstantResolver.lookupAndCacheConstant(ConstantResolver.java:128)
at jnr.constants.platform.ConstantResolver.getConstant(ConstantResolver.java:116)
at jnr.constants.platform.ConstantResolver.longValue(ConstantResolver.java:179)
at jnr.constants.platform.OpenFlags.intValue(OpenFlags.java:30)
at org.jruby.RubyFile.createFileClass(RubyFile.java:140)
at org.jruby.Ruby.initCore(Ruby.java:1547)
@SFEley
SFEley / gist:2cb2b0101ac2e534515db10d8711562c
Created September 19, 2018 18:34
JrJackson test run in JRuby 9.2.0.0
❯ rake test
/Users/Serah/dev/misc/jrjackson/test/jrjackson_test.rb:343: warning: Ambiguous first argument; make sure.
/Users/Serah/dev/misc/jrjackson/test/jrjackson_test.rb:373: warning: Ambiguous first argument; make sure.
/Users/Serah/.rbenv/versions/jruby-9.2.0.0/lib/ruby/gems/shared/gems/power_assert-1.1.3/lib/power_assert.rb:8: warning: tracing (e.g. set_trace_func) will not capture all events without --debug flag
/Users/Serah/.rbenv/versions/jruby-9.2.0.0/lib/ruby/gems/shared/gems/power_assert-1.1.3/lib/power_assert.rb:8: warning: tracing (e.g. set_trace_func) will not capture all events without --debug flag
Loaded suite /Users/Serah/.rbenv/versions/jruby-9.2.0.0/lib/ruby/gems/shared/gems/rake-12.3.1/lib/rake/rake_test_loader
Started
.F
================================================================================
org/jruby/RubyKernel.java:1175:in `catch'
@SFEley
SFEley / NEW Everyone Who Has Not Purchased.rb
Created July 6, 2016 21:35
Old/New Purchase Segments Comparison - Store 1214
NEW Everyone Who Has Not Purchased (1214)
Customers: 459545
Emails: 459543
{"top_five_product_ids"=>[],
"month_to_date_sales"=>0.0,
"total_sales"=>0.0,
"sales_by_month"=>{},
"lifetime_sales"=>0.0,
"average_order_value"=>0.0,
@SFEley
SFEley / NEW Everyone Who Has Not Purchased.rb
Last active July 6, 2016 20:57
Old/New Purchase Segments Comparison - Store 1107
NEW Everyone Who Has Not Purchased (1107)
Customers: 370338
Emails: 370316
{"top_five_product_ids"=>[],
"month_to_date_sales"=>0.0,
"total_sales"=>0.0,
"sales_by_month"=>{},
"lifetime_sales"=>0.0,
"average_order_value"=>0.0,
@SFEley
SFEley / NEW Everyone Who Has Not Purchased.rb
Created July 6, 2016 20:10
Old/New Purchase Segments Comparison - Store 3753
NEW Everyone Who Has Not Purchased (3753)
Customers: 17411
Emails: 17411
{"top_five_product_ids"=>[],
"month_to_date_sales"=>0.0,
"total_sales"=>0.0,
"sales_by_month"=>{},
"lifetime_sales"=>0.0,
"average_order_value"=>0.0,
@SFEley
SFEley / NEW Everyone Who Has Not Purchased.rb
Created July 6, 2016 18:20
Old/New Purchase Segments Comparison - Store 3285
NEW Everyone Who Has Not Purchased (3285)
Customers: 90344
Emails: 90335
{"top_five_product_ids"=>[],
"month_to_date_sales"=>0.0,
"total_sales"=>0.0,
"sales_by_month"=>{},
"lifetime_sales"=>0.0,
"average_order_value"=>0.0,
@SFEley
SFEley / consumer.rb
Last active June 7, 2016 21:52
Update all customers with average_order_value
include RedisCache
updater = Customer.mongo_client['customers']
start = 5000
lastid, lastaov = nil, nil
while (aovs = redis.zrange 'average_order_values', start, start + 999, withscores: true).present?
redis.pipelined do
aovs.each do |id, aov|
lastid, lastaov = id, aov
updater.find_one_and_update({ _id: BSON::ObjectId.from_string(id) }, { '$set' => { average_order_value: aov } })