Skip to content

Instantly share code, notes, and snippets.

View ryenski's full-sized avatar
🎯
Focusing

Ryan Heneise ryenski

🎯
Focusing
View GitHub Profile
@ryenski
ryenski / json-to-csv-with-jq.md
Last active April 11, 2024 20:14
Convert json to csv with jq @csv filter

To convert json to csv with headers using jq and the @csv filter.

jq -r '[first|keys_unsorted] + map([.[]]) | .[] | @csv' example.json > converted.csv

This would work on a simple json structured like:

[
@ryenski
ryenski / constructors.js
Created February 28, 2024 22:44
Javascript Constructors
function HelloWorld(str) {
this.str = str;
this.speak = function() {
console.log("hello", this.str);
}
};
var h = new HelloWorld("world");
h.speak();
(new HelloWorld("Jupiter")).speak();
@ryenski
ryenski / one_time_code.rb
Created December 12, 2022 23:58
A small script to generate memorable one-time passcodes.
# A small script to generate memorable one-time codes.
#
# OneTimeCode.generate
# => "ubahow-idea-easy-aveda"
class OneTimeCode
def initialize(length = 12)
@length = length
@mod_result = MOD_RESULT.sample
end
@ryenski
ryenski / checkout.rb
Last active December 12, 2022 23:59
Stripe Webhooks Controller
# This example follows a Stripe webhook through the application life cycle.
# In this case, a customer has created a Checkout, which is an object in our application that acts like a shopping cart.
# It relates to the products that are being purchased and encapsulates the customer's existing record, or the data required to create a new customer.
class Checkout < ApplicationRecord
include Amountable
include BtcpayInvoice
include StripePaymentIntent
belongs_to :user, optional: true
{"version":1,"resource":"file:///Users/ryanheneise/Projects/api/src/services/fees/index.js","entries":[{"id":"DXVN.js","timestamp":1667270770299},{"id":"VJk1.js","timestamp":1667270856905},{"id":"pi2q.js","timestamp":1667271038502}]}
@ryenski
ryenski / client.rb
Last active December 13, 2022 00:05
# frozen_string_literal: true
module MxIsoagent
class Client
BOARDING_URL = Rails.configuration.mx_iso_agent['boarding_url']
CHECKOUT_URL = Rails.configuration.mx_iso_agent['checkout_url']
INVITE_CODE = Rails.configuration.mx_iso_agent['invite_code']
BOARDING_KEYS = Rails.configuration.mx_iso_agent['api_key']
BUSINESS_TYPES = [
@ryenski
ryenski / gravatar_helper.rb
Last active December 12, 2022 23:39
gravatar_helper.rb
# frozen_string_literal: true
module GravatarHelper
def gravatar_image_tag(email, attrs = {})
attrs = {
class: 'h-10 w-10 rounded-full'
}.update(attrs)
image_tag gravatar_url(email), attrs
end
@ryenski
ryenski / pix-brief.md
Last active October 14, 2019 17:42
Project Brief for PIX Portal

Project Brief for PIX Portal

We're looking for a talented and competent Ruby on Rails developer to help us re-engineer an existing app that's hard to maintain and expensive. The existing app is built using React on the frontend and Apache Airflow on the backend. We're going to re-engineer the app to make it more maintainable and remove some unneeded complexity that makes it difficult to maintain and expensive to develop.

The purpose of this app is to receive credit card processing reports, apply a markup algorithm, and then generate a report for each store based on the result.

About the app

The current process is handled by two separate apps:

# frozen_string_literal: true
# bundle exec rails runner create_accounts.rb
# An organization that the above users don't have access to
organization = Organization.find_or_create_by(slug: 'accounting-demo') do |o|
o.name = 'Accounting Demo'
o.invite_code = Rails.configuration.mx_iso_agent['invite_code']
end
@ryenski
ryenski / add_feature_flags_to_users.rb
Last active June 28, 2019 17:08
Feature Flags with Pundit
# Migration...
class AddFeatureFlagsToUsers < ActiveRecord::Migration[5.2]
def change
add_column :users, :feature_flags, :string, array: true, default: []
end
end