Skip to content

Instantly share code, notes, and snippets.

@arv25
arv25 / handler_eg.rb
Created August 7, 2014 15:37
Error handling for auth service
module Platform::Errors::Handler
def self.included(base)
base.rescue_from Exception do |error|
handle(self, error)
end
end
private
@arv25
arv25 / shared_ex_example
Created August 11, 2014 22:04
Misc_drawer_access shared example
#spec/support/value_limited_numeric_spec.rb
-------------------------------------------------------------------------------------------
shared_examples_for 'a value limited numeric column' do |columns|
columns.each do |col|
it 'has numeric columns with max value limits' do
expect(FactoryGirl.build(col, amount: 100_000)).to be_invalid
end
@arv25
arv25 / homeboy.rb
Created August 12, 2014 03:27
auto define methods on class from hash
class Homeboy
def initialize( params={} )
params.map do |kv|
self.instance_variable_set("@#{kv[0]}", kv[1])
self.class.send(:define_method, "#{kv[0]}") { kv[1] }
end
end
def to_s
instance_variables.map { |sym| "#{sym.to_s[1..-1]},#{self.send(sym.to_s[1..-1])}" }
@arv25
arv25 / events.js
Last active March 9, 2018 00:35
Events with Redux Spike
// Events with Redux Spike
// ES6
//event name helpers
var eventNameCounter = 0;
const nextEventName = () => {
eventNameCounter = eventNameCounter + 1;
return "foo-".concat(eventNameCounter).concat(" ");
}
@arv25
arv25 / keybase.md
Created March 30, 2018 18:22
Keybase.io github proof of identity

Keybase proof

I hereby claim:

  • I am arv25 on github.
  • I am massdefect (https://keybase.io/massdefect) on keybase.
  • I have a public key ASAU3O61jlgOO05eYCR1cuY04LHnj-Y91ZaglNnkdWT6Kgo

To claim this, I am signing this object:

@arv25
arv25 / index.js
Created September 8, 2020 14:38
Lambda calling lambda with trace id
// Lambda 1 - arv-foo
// Synchronous fn that will back API Gateway endpoint.
const AWS = require('aws-sdk');
const lambda = new AWS.Lambda();
const getRandomInt = (max) => Math.floor(Math.random() * Math.floor(max));
exports.handler = async (event, context) => {
console.log("event:", event)