Skip to content

Instantly share code, notes, and snippets.

View cbzehner's full-sized avatar
🚀

Chris Zehner cbzehner

🚀
View GitHub Profile
@cbzehner
cbzehner / Cargo.toml
Last active September 20, 2023 08:27
Prompt for missing values in Clap
[package]
name = "clap_prompt_example"
version = "0.1.0"
edition = "2021"
[dependencies]
clap = { version = "3.1", features = ["derive"] }
dialoguer = "0.10"
@cbzehner
cbzehner / console.sh
Created March 27, 2021 23:35
example/request_local_state with a non-unit error type on Guard 1
❯ cargo check
Checking request_local_state v0.0.0 (/Users/cbzehner/Projects/open-source/Rocket/examples/request_local_state)
error[E0053]: method `from_request` has an incompatible type for trait
--> request_local_state/src/main.rs:28:5
|
28 | async fn from_request(req: &'r Request<'_>) -> request::Outcome<Self, ()> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `std::string::String`, found `()`
|
= note: expected fn pointer `fn(&'r rocket::Request<'life0>) -> Pin<Box<(dyn std::future::Future<Output = rocket::outcome::Outcome<Guard1, (Status, std::string::String), ()>> + std::marker::Send + 'async_trait)>>`
found fn pointer `fn(&'r rocket::Request<'life0>) -> Pin<Box<(dyn std::future::Future<Output = rocket::outcome::Outcome<Guard1, (Status, ()), ()>> + std::marker::Send + 'async_trait)>>`
use scrypt::{scrypt_check, scrypt_simple, ScryptParams};
#[derive(Copy, Clone)]
enum Mode {
Raw,
Digest,
}
/// Securely store a password in a format where the raw value of the password is not acessible.
#[derive(Clone)]
@cbzehner
cbzehner / Dockerfile
Created February 26, 2020 07:36
Rocket Dockerfile
FROM rustlang/rust:nightly
MAINTAINER "cbzehner@gmail.com"
ENV BUILD_DIR=/usr/src/<app_name>
RUN mkdir -p $BUILD_DIR
WORKDIR $BUILD_DIR
# TODO: Confirm this is actually needed to run `diesel setup`
# RUN cargo install diesel_cli --no-default-features --features postgres
@cbzehner
cbzehner / largest_in_stack.py
Created May 1, 2018 19:15
Largest Item In Stack
class MaxStack(Stack):
def __init__(self):
Stack.__init__()
self.max = []
def push(self, item):
self.items.append(item)
if item > self.max):
self.max.push(item)
def find_love(r1, r2):
(x_start, x_end) = x_overlap(r1, r2)
(y_start, y_end) = y_overlap(r1, r2)
if x_start is None:
return "x_start there can be no love!"
if x_end is None:
return "x_end there can be no love!"
if y_start is None:
Ones where I could find T&C:
https://www.octoparse.com/terms-and-conditions
https://dexi.io/terms
https://www.screamingfrog.co.uk/seo-spider/terms-conditions/
https://www.import.io/terms-conditions/ (<-- They also have a GDPR section, might be interesting)
https://www.incapsula.com/terms-of-use.html
Others: You can try searching google with `site:<website> Terms` to only search a specific site for pages that have "Terms" somewhere on the site.
http://webscraper.io/
https://scrapy.org/
@cbzehner
cbzehner / mergesort.rs
Created March 12, 2018 02:52
An implementation of Merge Sort in Rust (with a little help from my friends!)
/// Sorts a slice in-place-ish with mergesort.
/// Time Complexity: O(n * log(n))
/// Space Complexity: O(n)
///
/// ```
/// use merge_sort::merge_sort;
///
/// let mut example = [1,4,2,5,3];
///
/// merge_sort(&mut example);
@cbzehner
cbzehner / wt-cli.sh
Created March 6, 2018 03:04
npm WARNings
cbzehner at MacBook-Pro-4 ~/projects[SUCCESS]
$npm i -g wt-cli
npm WARN deprecated coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
/usr/local/bin/wt-cli -> /usr/local/lib/node_modules/wt-cli/bin/wt
/usr/local/bin/wt -> /usr/local/lib/node_modules/wt-cli/bin/wt
/usr/local/bin/auth0 -> /usr/local/lib/node_modules/wt-cli/bin/auth0
> fsevents@1.1.3 install /usr/local/lib/node_modules/wt-cli/node_modules/fsevents
> node install
@cbzehner
cbzehner / boringtask.sql
Created March 3, 2018 05:58
Movie Programming
SELECT
name as full_name,
dob as birthday,
job as profession,
loc as office,
role as title
FROM employees
WHERE
profession LIKE '%ngineer%'
AND loc IN ['Fremont', 'San Francisco', 'Sunnyvale']