Skip to content

Instantly share code, notes, and snippets.

@futurepaul
futurepaul / audioplayer.js
Created March 2, 2020 15:40
Code on tape (meta)
import React, { useState, useRef } from "react";
function decimalToTime(seconds, duration) {
let fmtTime = new Date(1000 * seconds).toISOString().substr(11, 8);
if (duration >= 3600) {
return fmtTime;
} else {
//remove the hours
fmtTime = fmtTime.substring(3);
@futurepaul
futurepaul / layout.md
Last active August 19, 2019 01:04
how to make a button

SCENARIO 1: BUTTON WIDTH IS BASED ON LABEL WIDTH

I want the width of the button to be: padding_left + label_width + padding_right

I want the height of the button to be: padding_top + label_height + padding_bottom

I want the label centered horizontally and vertically

@futurepaul
futurepaul / example.rs
Last active December 12, 2022 21:08
example usage of miniscript
use bitcoin::blockdata::{opcodes, script};
use miniscript::{Descriptor, Miniscript, Policy};
use std::str::FromStr;
use secp256k1;
fn key_from_secret_key(sk: secp256k1::SecretKey, secp: &secp256k1::Secp256k1<secp256k1::All>) -> bitcoin::PublicKey {
bitcoin::PublicKey {
key: secp256k1::PublicKey::from_secret_key(
Verifying my Blockstack ID is secured with the address 18mV3sRwd1kiR1YwvGBvrvxXj9fxqCVojG https://explorer.blockstack.org/address/18mV3sRwd1kiR1YwvGBvrvxXj9fxqCVojG
@futurepaul
futurepaul / whynot.py
Created March 14, 2018 17:46
The “Why’d you push that button” button
#Step 1: Import the libraries we need
import pygame.mixer
import RPi.GPIO as GPIO
import glob
import random
import time
#Step 2: Fire up the sound mixer
pygame.mixer.init()

Keybase proof

I hereby claim:

  • I am futurepaul on github.
  • I am futurepaul (https://keybase.io/futurepaul) on keybase.
  • I have a public key whose fingerprint is 2A20 458D 8270 EE78 2075 F488 6342 FAC3 3419 543C

To claim this, I am signing this object:

@futurepaul
futurepaul / rps.clj
Last active August 29, 2015 14:13
rock paper scissors
(def rps-rules {"rock" "scissors",
"paper" "rock",
"scissors" "paper"})
(defn rps-random []
(let [comp-choice (int (* (rand) 3))]
((into [] (keys rps-rules)) comp-choice)))
(defn rps-winner [choice comp-choice]
(if (= (rps-rules choice) comp-choice)
@futurepaul
futurepaul / Flood.swift
Last active April 18, 2016 15:19
The biblical flood, in Swift
let 🌍 = "🐶🐺🐱🐭🐹🐰🐸🐯🐨🐻🐷🐽🐮🐗🐵🐒🐴🐑🐘🐼🐧🐦🐤🐥🐣🐔🐍🐢🐛🐝🐜🐞🐌🐙🐚🐠🐟🐬🐳🐋🐄🐏🐀🐃🐅🐇🐉🐎🐐🐓🐕🐖🐁🐂🐲🐡🐊🐫🐪🐆🐈🐩"
var 🚢: String[] = []
for 💕 in 🌍 {
switch 💕 {
case "🐑", "🐏", "🐐", "🐂":
for 🛁 in 1...7 {
🚢.append(💕 + 💕)
}