Skip to content

Instantly share code, notes, and snippets.

Avatar

Andy Koch somazx

View GitHub Profile
View ContactMenu.vue
<template>
<v-list-tile-action v-if="email || phone || phone2">
<v-menu>
<template v-slot:activator="{ on }">
<v-btn flat v-on="on">
<v-icon color="blue">fa-comment-dots</v-icon>
</v-btn>
</template>
<v-list>
@somazx
somazx / scraper.js
Last active Sep 18, 2020
Humble Bundle Unredeemed Keys Scraper
View scraper.js
/*
Purpose: easily obtain a list of your humble bundle games that haven't been redeemed.
Instructions:
1) Log into Humble Bundle as usual.
2) Navigate to https://www.humblebundle.com/home/keys
3) Open browser console and run the following script in the console
Script will dump to console the scraped list of all your unredeemed game keys.
View application.rb
# config/application.rb
config.autoload_paths = Dir['app/domains/*/*/']
@somazx
somazx / modern_rails.md
Last active Dec 31, 2018
Improved Rails
View modern_rails.md

Pain Points in Rails

Rails has several pain-points for more complex web applicatoins that frameworks like Hanami and Trailblazer attempt to address. By addressing theses issues your business logic is better isolated from the framework details/implementation, clearer responsibilities, easier reasoning about, cleaner code, creates opportunity for easy further abstraction when necessary, allows for simpler testing, etc.

Identified Pain Points and potential solutions

Better file structure/autoloading that allows grouping of domain concerns under a single folder structure

Solutions: use custom autoload_paths/eager_load_paths in an initializer?

View keybase.md

Keybase proof

I hereby claim:

  • I am somazx on github.
  • I am somazx (https://keybase.io/somazx) on keybase.
  • I have a public key ASC6zNYYHXFpwjIR-jMU4mCTT90NtXeNrzhD-k2mU-vd4go

To claim this, I am signing this object:

@somazx
somazx / nested, serialized dataobjects.md
Last active Nov 3, 2020
Working with nested, serialized dataobjects in Rails
View nested, serialized dataobjects.md

Rails and serialized nested DataObjects

I wanted to store arbitrary nested data structures in a jsonb column and be able to retrieve and work with that data seemlessly within a Rails application. There are several tutorials covering different aspects of this, but none felt complete to me.

For this example we'll be working with a User model that can define surveys. Each survey consists of n multiple choices questions, and each question can have between two and ten answer options.

Requirements:

In this case we use Postgresql's JSONB support to store the data, but you could also use other forms of serializing such as a text column and Rails' default YAML serializing. JSONB is chosen in this case because it leaves open the possiblity of querying the data with SQL. Also, apparently serializing to JSON is much faster.[1]

@somazx
somazx / Gemfile
Last active Feb 1, 2017
Using Amazon Elasticsearch securely (signed requests) with Rails & searchkick gem on Heroku.
View Gemfile
gem 'elasticsearch', '>= 1.0.15'
gem 'elasticsearch-model'
gem 'elasticsearch-rails'
gem 'patron'
gem 'faraday_middleware-aws-signers-v4'
gem 'searchkick'
You can’t perform that action at this time.