This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// music.setVolume(100) | |
enum PlaneState { | |
Idle, // No Sound | |
Liftoff, // playTone Note.D | |
Cruising, // playTone Note.CSharp | |
Left, // playTone Note.G | |
Right, // playTone Note.B | |
Turbulence, //music.playMelody("G B C C -- F F G", 300) | |
Landing, //playTone Note.C |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Answer from https://stackoverflow.com/a/490203 | |
from PyPDF2 import PdfFileWriter, PdfFileReader | |
inputpdf = PdfFileReader(open("document.pdf", "rb")) | |
for i in range(inputpdf.numPages): | |
output = PdfFileWriter() | |
output.addPage(inputpdf.getPage(i)) | |
with open("document-page%s.pdf" % i, "wb") as outputStream: | |
output.write(outputStream) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import WebKit | |
import Combine | |
class WebViewData: ObservableObject { | |
@Published var loading: Bool = false | |
@Published var scrollPercent: Float = 0 | |
@Published var url: URL? = nil | |
@Published var urlBar: String = "https://nasa.gov" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WHITESPACE = _{NEWLINE | " " | "\n" | "\t"} | |
SchemaString = {"\"" ~ (("\\" ~ "\"") | (!"\"" ~ ANY))+ ~ "\"" ~ ("@" ~ ASCII_ALPHA+)? } | |
UrlNode = {(!(">" | "<") ~ ANY)+} | |
TAG = { "<" ~ UrlNode ~ ">"} | |
// Use url = "2.1" to parse out URLs...need to extract protocol, hostname, path, search, fragment | |
// A UrlNode is "subClassOf" "http://www.w3.org/2000/01/rdf-schema" "http://www.w3.org/2000/01/rdf-schema#subClassOf" | |
TRIPLE = { TAG ~ TAG ~ (TAG | SchemaString) ~ "." } | |
parse = { | |
SOI ~ TRIPLE* | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type TypeState = Distribute<keyof FlowMachineSchema["states"], FlowMachineContext> // assuming same context | |
export type Send = Interpreter<FlowMachineContext, FlowMachineSchema, FlowEvents, TypeState>['send'] | |
export type Context = [ | |
State<FlowMachineContext, FlowEvents, FlowMachineSchema, TypeState>, | |
Send, | |
Interpreter<FlowMachineContext, FlowMachineSchema, FlowEvents, TypeState> | |
]; | |
type Distribute<U, C> = U extends any ? { value: U; context: C } : never // util |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use core::hash::Hash; | |
use std::sync::Arc; | |
use core::any::Any; | |
use core::any::TypeId; | |
use std::collections::HashMap; | |
use async_trait::async_trait; // 0.1.36 | |
use tokio; // 0.2.21 | |
use tokio::sync::RwLock; | |
// Our trait. The async part is not necessary, I just wanted to see how it behaves :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let n = 8; | |
let mut blank = Vec::with_capacity(8); | |
hanoi(n, &mut (0..8).collect(), &mut blank.clone(), &mut blank); | |
} | |
//if n > 0 | |
// Hanoi(n − 1, src, tmp, dst) 〈〈Recurse!〉〉 | |
// move disk n from src to dst | |
// Hanoi(n − 1, tmp, dst, src) 〈〈Recurse!〉〉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use syntect::highlighting::ThemeSet; | |
use syntect::html::highlighted_html_for_string; | |
use syntect::parsing::SyntaxSet; | |
use pulldown_cmark::{html, CodeBlockKind, CowStr, Event, Options, Parser, Tag}; | |
fn main() { | |
// Setup for pulldown_cmark to read (only) from stdin | |
let opts = Options::all(); | |
let input = String::from( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::convert::TryFrom; | |
#[derive(Debug, Copy, Clone)] | |
enum HttpMethod { | |
GET, | |
POST, | |
PUT | |
} | |
impl TryFrom<String> for HttpMethod { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /Users/dknopoff/.config/tmuxinator/portal.yml | |
name: def | |
root: ~/Documents | |
# Optional tmux socket | |
# socket_name: foo | |
# Note that the pre and post options have been deprecated and will be replaced by | |
# project hooks. |