Skip to content

Instantly share code, notes, and snippets.

import tensorflow as tf
import os
print("TensorFlow version:", tf.__version__)
mnist = tf.keras.datasets.mnist
CWD = '' if os.getcwd() == '/' else os.getcwd()
(x_train, y_train), (x_test, y_test) = mnist.load_data('/inputs/mnist.npz')
x_train, x_test = x_train / 255.0, x_test / 255.0
@jochasinga
jochasinga / movies2.csv
Last active December 5, 2022 07:53
A movie dataset based on directors, categories, and IMDB ratings.
movie_name director category imdb_rating watched
Kill Bill Vol. 1 0 0 8.2 0
Pulp Fiction 0 0 8.3 0
Django Unchained 0 0 8.4 1
Inglourious Basterds 0 0 8.3 0
Avatar 1 1 7.8 0
Titanic 1 2 7.9 1
Alien 1 1 8.4 0
A Beautiful Mind 2 2 8.2 0
Apollo 13 2 2 7.7 1
@jochasinga
jochasinga / movies.csv
Last active December 2, 2022 13:48
CSV file of movies with directors
movie_name director category imdb_rating watched
Kill Bill Vol. 1 Quentin Tarantino Action 8.2 Yes
Pulp Fiction Quentin Tarantino Action 8.3 Yes
Django Unchained Quentin Tarantino Action 8.4 No
Inglourious Basterds Quentin Tarantino Action 8.3 Yes
Avatar James Cameron Scifi 7.8 Yes
Titanic James Cameron Drama 7.9 No
Alien James Cameron Scifi 8.4 Yes
A Beautiful Mind Ron Howard Drama 8.2 Yes
Apollo 13 Ron Howard Drama 7.7 No
@jochasinga
jochasinga / python_web3storage.py
Last active July 20, 2022 18:56
Uploading the Iris dataset to web3storage API and back as Panda dataframe
import pandas as pd
import requests
base_url = "https://api.web3.storage"
headers = {"Authorization": "Bearer <YOUR_API_TOKEN>"}
response = requests.post(base_url + '/upload', headers=headers, data=open('./iris.csv', 'rb'))
pprint(response.json())
cid = response.json()["cid"]
@jochasinga
jochasinga / test.spec.js
Created July 15, 2022 15:59
A test measuring elapsed time for calling `store` and `storeDirectory`
import { NFTStorage, File } from 'nft.storage'
describe('storeDirectory', () => {
const { AUTH_TOKEN, SERVICE_ENDPOINT } = process.env
const token = AUTH_TOKEN || ''
const endpoint = new URL(SERVICE_ENDPOINT || '')
let client = new NFTStorage({token, endpoint})
let times = []
it('testing elapsed time for storeDirectory', async () => {
@jochasinga
jochasinga / eventTicket.sol
Created July 14, 2022 22:10
Implementing event tickets as ERC-1155 tokens
// contracts/EventTickets.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.6;
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
contract EventTicket is ERC1155 {
// Declare all the type IDs
uint256 public constant GENERAL = 0;
uint256 public constant VIP = 1;
uint256 public constant RSVP = 2;
@jochasinga
jochasinga / mintBatch.sol
Created July 14, 2022 22:05
Call to _mintBatch in an ERC-1155 Solidity contract
ERC1155._mintBatch(receiverAddress, [5, 6, 7, 8, /* … */, 105], [1, 1, 1, 1, /* … */ 1], "");
@jochasinga
jochasinga / main.rs
Last active February 1, 2022 21:12
Counter app written in Yew functional components
use yew::prelude::*;
#[derive(Properties, PartialEq)]
struct TodoProps {
state: UseStateHandle<u64>,
}
#[function_component(Counter)]
fn counter(props: &TodoProps) -> Html {
@jochasinga
jochasinga / main.rs
Last active February 1, 2022 18:04
Counter app written in Yew
/// Import all goodies from Yew.
use yew::prelude::*;
/// Our app's state. It is now just a unit struct with no property
/// because our state will be encapsulated within the Counter component.
struct App;
/// A Counter functional component ala React.
#[function_component(Counter)]
fn counter() -> Html {
person_age person_income person_home_ownership person_emp_length loan_intent loan_grade loan_amnt loan_int_rate loan_status loan_percent_income cb_person_default_on_file cb_person_cred_hist_length
22 59000 RENT 123.0 PERSONAL D 35000 16.02 1 0.59 Y 3
21 9600 OWN 5.0 EDUCATION B 1000 11.14 0 0.1 N 2
25 9600 MORTGAGE 1.0 MEDICAL C 5500 12.87 1 0.57 N 3
23 65500 RENT 4.0 MEDICAL C 35000 15.23 1 0.53 N 2
24 54400 RENT 8.0 MEDICAL C 35000 14.27 1 0.55 Y 4
21 9900 OWN 2.0 VENTURE A 2500 7.14 1 0.25 N 2
26 77100 RENT 8.0 EDUCATION B 35000 12.42 1 0.45 N 3
24 78956 RENT 5.0 MEDICAL B 35000 11.11 1 0.44 N 4
24 83000 RENT 8.0 PERSONAL A 35000 8.9 1 0.42 N 2