Skip to content

Instantly share code, notes, and snippets.

@blakewest
blakewest / creditDesk.sol
Created April 26, 2021 15:02
Solidity Blogpost #1: Config Contract, snippet 7
import "./GoldfinchConfig.sol";
import "./ConfigHelper.sol";
contract CreditDesk {
GoldfinchConfig public config;
using ConfigHelper for config;
function drawdown(CreditLine creditLine, uint256 amount) public {
require(validCreditLine(creditLine), "invalid creditline!");
require(msg.sender == creditLine.owner())
@blakewest
blakewest / creditDesk.sol
Created April 26, 2021 15:00
Solidity Blogpost #1: Config Contract, snippet 6
import "./GoldfinchConfig.sol";
import "./ConfigHelper.sol";
contract CreditDesk {
GoldfinchConfig public config;
// This line is what "adds" the library methods to the config. If you aren't
// familiar with this syntax, you can just Google how libraries work in Solidity
using ConfigHelper for config;
function createCreditLine(CreditLineParams params) public {
@blakewest
blakewest / configHelper.sol
Created April 26, 2021 14:57
Solidity Blogpost #1: Config Contract, snippet 5
import "./GoldfinchConfig.sol";
import "../../interfaces/ICreditLineFactory.sol";
library ConfigHelper {
function getCreditLineFactory(GoldfinchConfig config) internal view returns(ICreditLineFactory) {
return ICreditLineFactory(creditLineFactoryAddress(config));
}
function creditLineFactoryAddress(GoldfinchConfig config) internal view returns (address) {
return config.addresses(0);
@blakewest
blakewest / creditDesk.sol
Last active April 26, 2021 15:11
Solidity Blogpost #1: Config Contract, snippet 4
import "./GoldfinchConfig.sol";
import "./ICreditLineFactory.sol";
contract CreditDesk {
GoldfinchConfig public config;
function createCreditLine(CreditLineParams params) public {
require(validParams(params), "invalid params!");
uint256 maxCreditLineAmount = config.numbers(0);
require(params.amount <= maxCreditLineAmount, "Amount is above maximum");
@blakewest
blakewest / config.sol
Last active April 26, 2021 14:56
Solidity Blogpost #1: Config Contract, snippet 3
contract GoldfinchConfig is Ownable {
// Note: Solidity creates automatic getter methods for these mappings
// So we don't need to explicitly add them ourselves.
mapping(uint256 => address) public addresses;
mapping(uint256 => uint256) public numbers;
event AddressUpdated(address owner, uint256 index, address oldValue, address newValue);
event NumberUpdated(address owner, uint256 index, uint256 oldValue, uint256 newValue);
function setAddress(uint256 addressIndex, address newAddress) public onlyAdmin {
@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");
@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 / mnist_example.ipynb
Created February 9, 2018 17:26
Example implementation of a Convolutional Neural Net for the MNIST data
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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
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