Skip to content

Instantly share code, notes, and snippets.

@ltfschoen
ltfschoen / string-conversion.rs
Created November 8, 2021 09:55 — forked from jimmychu0807/string-conversion.rs
Conversion between String, str, Vec<u8>, Vec<char> in Rust
use std::str;
fn main() {
// -- FROM: vec of chars --
let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}'];
// to String
let string1: String = src1.iter().collect::<String>();
// to str
let str1: &str = &src1.iter().collect::<String>();
// to vec of byte
@ltfschoen
ltfschoen / proportions_of_missing_data_in_dataframe_columns.py
Last active October 20, 2021 07:43
Calculate percentage of NaN values in a Pandas Dataframe for each column. Exclude columns that do not contain any NaN values
# Author: Luke Schoen 2017
import pandas as pd
import numpy as np
import functools
# Create DataFrame
# df = pd.DataFrame(np.random.randn(10,2))
# Populate with NaN values
df = pd.DataFrame({'col1': ['1.111', '2.111', '3.111', '4.111'], 'col2': ['4.111', '5.111', np.NaN, '7.111'], 'col3': ['8', '9', np.NaN, np.NaN], 'col4': ['12', '13', '14', '15']})
@ltfschoen
ltfschoen / w3f-polkadot-wiki-notes.md
Last active July 11, 2021 14:50
W3F Polkadot Wiki Notes

Accounts

Different accounts are used to manage funds. The underlying cryptography of their account keys is the same:

Stash

  • Primary account
  • Holds funds. Usually a cold wallet (on piece of paper in a safe, or protected by layers of hardware security)
  • Bonds (locks) a portion of its funds with a Controller for participation (since the stake key is kept offline)
  • Unbonding requires waiting ~600 blocks before unlocked funds accessible again
@ltfschoen
ltfschoen / get_keys_from_associative_array.js
Last active April 18, 2021 00:51
Object(keys) Helper Function for ExtendScript
// Custom Helper function for ExtendScript (Adobe CEP) created as an alternative since JavaScript Object(keys) method does not work
var getKeysWithoutObjectKeysSupport = function(associativeArrayObject) {
var arrayWithKeys=[], associativeArrayObject;
for (key in associativeArrayObject) {
// Avoid returning these keys from the Associative Array that are stored in it for some reason
if (key !== undefined && key !== "toJSONString" && key !== "parseJSON" ) {
arrayWithKeys.push(key);
}
}
@ltfschoen
ltfschoen / subkey.sh
Last active March 14, 2021 08:20
Polkadot Address Generation with Subkey
#!/bin/sh
# Start Ubuntu in container and install dependencies
docker run --name ubuntutest -t -i ubuntu /bin/bash
apt-get update
apt-get install -y curl
curl https://getsubstrate.io -sSf | bash -s -- --fast
# Install Substrate and Subkey
cargo install --force subkey --git https://github.com/paritytech/substrate --version 2.0.0 --locked
@ltfschoen
ltfschoen / query_string_to_map.ex
Created January 28, 2018 07:38
Elixir Convert Query String Parameters into Map (Key/Value Pairs)
# Convert Query String Parameters into Map (Key/Value Pairs)
# Output is: `%{"from" => "ME", "proof" => "PROVEN", "to" => "YOU", "to_index" => "THERE"}`
String.split("from=ME&to=YOU&to_index=THERE&proof=PROVEN", ~r/&|=/) |> Enum.chunk(2) |> Map.new(fn [k, v] -> {k, v} end)
@ltfschoen
ltfschoen / rotki.md
Created August 27, 2020 23:08
Rotki release steps to verify checksum

The following are steps taken to verify the checksum of the Rotki installer on macOS:

  • Downloaded the file (i.e. rotki-darwin-v1.6.2.dmg.sha512) that contains the published SHA512 hash of binaries that we'll use as checksum to verify the integrity of the binary
  • View the checksum in the file with cat rotki-darwin-v1.6.2.dmg.sha512
    • Example output was:
f1be8965f206fb0ae5f745575c0e4da12a302e237188bb5cd41d73a19705965fc409da72508253f8908626ccbfb43990bf0e801f3cfa0ff9e29000c7d177a074  rotki-darwin-v1.6.2.dmg
@ltfschoen
ltfschoen / flutter.md
Last active August 3, 2020 01:54
flutter-notes.md
# shasum checksum 256 for https://www.osboxes.org/debian/
shasum -a 256 10G-64bit.7z
brew install p7zip
# extract
7za x 10G-64bit.7z
# gpg verify
cat checksums.txt
shasum -a 256 mac_1.7.8_MyCrypto.dmg
@ltfschoen
ltfschoen / acala.md
Last active July 30, 2020 10:12
Acala