This file contains 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::io; | |
use std::io::Write; | |
use std::fmt::{Debug, Formatter, Error}; | |
use std::thread; | |
use std::time::Duration; | |
use std::sync::{Arc, Mutex}; | |
#[derive(Clone)] | |
struct Output<W>(Arc<Mutex<W>>); |
This file contains 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 Predicates = std::collections::BTreeMap<Predicate, String>; | |
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | |
struct Predicate(fn(u64) -> bool); | |
fn main() { | |
let inputs = 0..=100; | |
let mut predicates = Predicates::new(); | |
predicates.insert(Predicate(|v| v % 3 == 0), "Fizz".to_string()); | |
predicates.insert(Predicate(|v| v % 5 == 0), "Buzz".to_string()); |
This file contains 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
# unstaged changes | |
git diff --name-only --diff-filter=ACMR | sed 's| |\\ |g' | |
# staged changes | |
git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g' |
This file contains 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
hello: ## sends greetings | |
@echo "Hello!" | |
help: ## prints the help | |
@echo "# Makefile Help #" | |
@grep -E '^[a-zA-Z0-9_-]+:.*##' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":([^:])*?## "}; {split($$1,m,/:/); if (!m[2]) m[2]=$$1; printf "\033[36m%-30s\033[0m %s\n", m[2], $$2}' |
This file contains 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
#!/bin/sh | |
# time execution | |
time bin/rubocop -L --stderr $(git diff --name-only --cached | grep '\.rb') | |
# bare minimum | |
bin/rubocop $(git diff --name-only --cached | grep '\.rb') | |
# -L = list files (good to see which one got checked since we don't see the nested command's output | |
# --stderr = may or may not be useful to pipe output there |
This file contains 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
// https://rust-lang.github.io/api-guidelines/future-proofing.html | |
/* | |
The following traits should never be used in bounds on data structures: | |
* Clone | |
… | |
*/ | |
#[derive(Clone, Debug)] |
This file contains 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
# .github/workflows/delete-branch.yaml | |
name: Delete unmerged branch | |
on: | |
pull_request: | |
branches: [ main ] | |
types: [ closed ] | |
jobs: | |
worker: |
This file contains 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
FROM postgres:11.5 | |
RUN apt-get update && apt-get install -y curl | |
RUN curl https://dl.2ndquadrant.com/default/release/get/deb | bash && apt-get update | |
### IMPORTANT: use 2.2.2 instead of 2.2.1! Otherwise PG 11.5 is very sad! | |
RUN apt-get install -y -V postgresql-${PG_MAJOR}-pglogical=2.2.2-1.stretch+1 | |
# the following copied from https://github.com/reediculous456/docker-pglogical/blob/master/Dockerfile |
This file contains 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
[core] | |
# ... | |
[init] | |
defaultBranch = main | |
[commit] | |
gpgsign = true | |
# you want that to have a default for locations outside of your regular dev folders |
This file contains 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
// Fetch - readable on origin only (it does make the call though) | |
let res = await (async () => { | |
const url = "https://markentier.tech/feed.json"; | |
// const url = "https://dummy.restapiexample.com/api/v1/employee/9"; | |
const res = await fetch(url, { mode: "no-cors" }); | |
if(res.ok && res.status === 200) { | |
const body = await res.json(); | |
return {body} | |
// const headers = Object.fromEntries(res.headers); | |
// return { body, headers } |
NewerOlder