Skip to content

Instantly share code, notes, and snippets.

# Pseudo code for doing a big zuora export
# Pull all_account_ids from a CSV export, or potentially from ActiveZuora::Account. Only issue with the latter
# is that it might timeout if you have too many accounts.
all_account_ids.each do |account_id|
list_of_all_soap_objects.each do |soap_object|
# A soap_object would be something like Invoice, Payment, CreditBalanceAdjustment, etc.
active_zuora_klass = "ActiveZuora::#{soap_object}".constantize
active_zuora_klass.where(account_id: account_id).find_each do |zuora_object|
# This is just a placeholder. I'm not sure what database you'd use to actually store things.
@blakewest
blakewest / naming_journal.rb
Last active September 19, 2016 21:11
A place to write down snippets of the process we go through when naming things.
# 1
# Method name history was...
# nil (did both things in one method) --> generate_csv_for_revenue_lines
def generate_csv_for_revenue_lines(revenue_lines)
# name history...
# res -> pg_result
pg_result = execute_sql("SELECT * FROM recognized_revenue WHERE" +
+ " revenue_line_id IN (?)", revenue_lines.pluck(:id).join(",")
)
pg_result.values
class Forest::MembershipPatient
include ForestLiana::Collection
collection :membership_patients
field :name, type: 'String' do |object|
::MembershipPatient.unscoped.find(object.id).name
end
end
@blakewest
blakewest / procedures_api.js
Last active June 2, 2017 01:05
Procedures API Option 1.1 ("procedures w/ visit_id")
/*
// Option 1: Procedures with visit_id
// Standard CRUD actions to /api/provider/procedures
// GET /api/provider/procedures
// POST /api/provider/procedures
// GET /api/provider/procedures/:id
// PATCH /api/provider/procedures/:id
// DELETE /api/provider/procedures/:id
@blakewest
blakewest / procedures_api2.js
Last active June 2, 2017 01:15
Options 2 ("Visits") for Hint Procedures API
/*
// Option 2: Visits
// Standard CRUD actions to /api/provider/visits
// GET /api/provider/visits
// POST /api/provider/visits
// GET /api/provider/visits/:id
// PATCH /api/provider/visits/:id
// DELETE /api/provider/visits/:id
FROM quay.io/aptible/java:oracle-java8
ENV JAVA_HOME /usr/lib/jvm/java-8-oracle
RUN apt-get update && apt-get -y install libc6-dev unzip curl
RUN groupadd looker && useradd -m -g looker -s /bin/bash looker
ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.5/supercronic-linux-amd64 \
SUPERCRONIC=supercronic-linux-amd64 \
SUPERCRONIC_SHA1SUM=9aeb41e00cc7b71d30d33c57a2333f2c2581a201
@blakewest
blakewest / logistic_regression_example.py
Created February 5, 2018 22:38
A starter implementation for logistic regression.
import pandas as pd
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import confusion_matrix
from sklearn.model_selection import train_test_split
def load_data(path):
# Load the data into a Pandas dataframe.
raw_data = pd.read_csv(path, header=0)
print('Loaded data from', path)
return raw_data
@blakewest
blakewest / mnist_example.ipynb
Created February 9, 2018 17:26
Example implementation of a Convolutional Neural Net for the MNIST data
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@blakewest
blakewest / creditDesk.sol
Created April 26, 2021 14:49
Solidity Blogpost #1: Config Contracts, snippet 1
import "./ICreditLineFactory.sol";
contract CreditDesk {
address public creditLineFactoryAddress;
function createCreditLine(CreditLineParams params) public {
require(validParams(params), "invalid params!");
ICreditLineFactory(creditLineFactoryAddress).createCreditLine(params);
}
@blakewest
blakewest / creditDesk.sol
Created April 26, 2021 14:50
Solidity Blogpost #2: Config Contract
import "./ICreditLineFactory.sol";
contract CreditDesk {
address public creditLineFactoryAddress;
uint256 public maxCreditLineAmount;
address public protocolOwner;
function createCreditLine(CreditLineParams params) public onlyOwner {
require(validParams(params), "invalid params!");
require(params.amount <= maxCreditLineAmount, "Amount is above maximum");