Skip to content

Instantly share code, notes, and snippets.

View JosephTLyons's full-sized avatar
🛏️

Joseph T. Lyons JosephTLyons

🛏️
View GitHub Profile
@JosephTLyons
JosephTLyons / gist:8c22fdf549917a7ee4f83b943f5863c7
Created June 14, 2023 22:13
Setting up mix formatter for Elixir in Zed
Source: https://github.com/zed-industries/community/issues/1526#issuecomment-1543891012
{
// ...
"language_overrides": {
"Elixir": {
"format_on_save": {
"external": {
"command": "mix",
"arguments": ["format", "--stdin-filename", "{buffer_path}", "-"]
}
@JosephTLyons
JosephTLyons / main.rs
Last active April 10, 2023 09:16
Pretend filesystem in Rust
enum Item {
File(File),
Directory(Directory),
}
struct File {
name: String,
}
impl File {
@JosephTLyons
JosephTLyons / main.py
Last active April 10, 2023 06:21
Pretend filesystem in Python
class File:
def __init__(self, name, contents=""):
self.name = name
self.content = contents
class Directory:
def __init__(self, name, items):
self.name = name
self.items = items
[main] <------- [preview] <------- [stable]
^ ^ ^
| | stable release bug PRs target this branch, then stable -> preview, then preview -> main
| |
| preview release bug PRs target this branch, then preview -> main
|
new feature PRs target this branch, bug fix PRs relating to new features target this branch
One release day, merge
- merge preview -> stable
@JosephTLyons
JosephTLyons / iter_to_string.rs
Last active May 3, 2022 05:47
A generic trait that converts iterables into a `String`
trait IterToString {
fn iter_to_string(self, separator: &str) -> String;
}
impl<T> IterToString for T
where
T: IntoIterator,
T::Item: ToString,
{
fn iter_to_string(self, separator: &str) -> String {
def create_markdown_table_lines(rows):
if not rows:
return []
create_row_string = lambda row: f"| {' | '.join(row)} |"
headers = list(rows[0].keys())
separators = ["-"] * len(headers)
lines = [
@JosephTLyons
JosephTLyons / loops.py
Last active April 9, 2022 07:30
Gentlemen's addition to spicy loops
# 1: A true classic
# --------------------------------------
animals = ["dog", "cat", "bird", "mouse", "goat"]
for animal in animals:
print(animal)
# 2: A dash of pepper ...
# --------------------------------------
/Users/josephlyons/Desktop/rust_temp/nushell/docs〉ps | first 2 | to json -i 4 02/20/2022 02:29:47 PM
[
{
"pid": 47434,
"name": "nu",
"status": "Running",
"cpu": 1.8518518518518519,
"mem": 14471168,
"virtual": 5180243968
},
@JosephTLyons
JosephTLyons / crypto.py
Created February 10, 2022 05:39
Helped a friend write some code...
from collections import defaultdict
currency_combo_strings = ["btcusd","btcgusd","btcdai","btcgbp","btceur","btcsgd","ethbtc","ethusd","ethgusd","ethgbp","etheur","ethsgd","ethdai","bchusd","bchbtc","bcheth","ltcusd","ltcbtc","ltceth","ltcbch","zecusd","zecbtc","zeceth","zecbch","zecltc","batusd","batbtc","bateth","linkusd","linkbtc","linketh","daiusd","oxtusd","oxtbtc","oxteth","filusd","ampusd","paxgusd","compusd","mkrusd","zrxusd","kncusd","storjusd","manausd","aaveusd","snxusd","yfiusd","umausd","balusd","crvusd","renusd","uniusd","enjusd","bntusd","1inchusd","sklusd","grtusd","lrcusd","sandusd","cubeusd","lptusd","bondusd","maticusd","injusd","sushiusd","dogeusd","api3usd","mirusd","ctxusd","alcxusd","ankrusd","ftmusd","xtzusd","axsusd","usdcusd","slpusd","lunausd","ustusd","mco2usd","dogebtc","dogeeth","cvcusd","spellusd","mimusd","galausd","mcusd","ensusd","elonusd","ashusd","wcfgusd","rareusd","radusd","qntusd","maskusd","fetusd","audiousd","nmrusd","rlyusd","rndrusd","shibusd","ldousd","kp3rusd","t
def get_color_for_text(text):
colors = [
"black",
"blue",
"green",
"orange",
"red",
"silver",
"white",
"yellow",