Skip to content

Instantly share code, notes, and snippets.

View kljensen's full-sized avatar
😵‍💫
0101010101

Kyle L. Jensen kljensen

😵‍💫
0101010101
View GitHub Profile
@frozolotl
frozolotl / 01_README.md
Last active October 28, 2024 01:29
A reimplementation of the default enum layout directly in Typst.

Note

It is more complex than it needs to be for most uses because it tries to be as feature-complete as possible.

@PgBiel
PgBiel / ref-enum-item.typ
Last active October 28, 2024 14:40
Referencing enum items in Typst 0.8.0
// MIT No Attribution
//
// Copyright (c) 2023 Pg Biel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify,
// merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so.
//
@mcroach
mcroach / storing-image-assets-in-repo.md
Last active January 8, 2025 13:09
Using an 'assets' branch to store images in your repo

Storing image assets in your repo and referencing in markdown

Create an assets branch and make the initial commit

git checkout --orphan assets
git reset --hard
cp /path/to/cat.png .
git add .
git commit -m 'Added cat picture'
git push -u origin assets
fzf-history-uniq() {
selected=$(
history 0 \
| awk '{
match($0, /^ *([0-9]+) *(.*)$/, r);
num=r[1]; cmd=r[2];
if(s[cmd]=="") { print cmd; s[cmd]=1; } }' \
| fzf --tac )
BUFFER="$selected"
zle end-of-line
@koreyou
koreyou / bm25.py
Created November 1, 2019 05:26
Implementation of OKapi BM25 with sklearn's TfidfVectorizer
""" Implementation of OKapi BM25 with sklearn's TfidfVectorizer
Distributed as CC-0 (https://creativecommons.org/publicdomain/zero/1.0/)
"""
import numpy as np
from sklearn.feature_extraction.text import TfidfVectorizer
from scipy import sparse
class BM25(object):
@jgoday
jgoday / main.rs
Created October 23, 2019 10:06
Postgres async notifications with tokio_postgres
#![feature(poll_map)]
use futures::{stream, StreamExt};
use futures::{FutureExt, TryStreamExt};
use std::env;
use tokio::sync::mpsc;
use tokio_postgres::{connect, NoTls};
#[tokio::main]
async fn main() {
let connection_parameters = env::var("DBURL").unwrap();
@amirasaran
amirasaran / smtp_server.py
Last active March 20, 2024 12:00
Python3 SMTP (smtpd) Mail Server with authentication sample + smtpd TLS support
import asynchat
import base64
import ssl
import asyncore
from smtpd import SMTPServer as BaseSMTPServer, SMTPChannel as BaseSMTPChannel, DEBUGSTREAM
def decode_b64(data):
"""Wrapper for b64decode, without having to struggle with bytestrings."""
@gene1wood
gene1wood / change-github-collaborators-permissions.md
Last active September 9, 2024 19:51
How to edit or modify a GitHub user's permissions on a repository through the API

The GitHub API is inconsistent for this endpoint. Normally to edit or modify a resource, the REST API uses the PATCH verb.

For the https://developer.github.com/v3/repos/collaborators/ endpoint however, to edit or modify a user's permissions, there is no PATCH verb. Instead you must make a PUT call defining the new permissions.

The documentation confusingly describes this as "Add user as a collaborator" when the user you're modifying already is a collaborator, you just want to change their permissions.

Here is an example call to change a user with push permissions to pull permissions

@omaraboumrad
omaraboumrad / splitlogs.py
Created October 6, 2017 14:18
View docker-compose services logs in split tmux panes
# Requires pyyaml
import os
import yaml
run = os.system
new_window = lambda cmd: run('tmux new-window -n "logs" "{}"'.format(cmd))
split_vertical = lambda cmd: run('tmux split-window "{}"'.format(cmd))
split_horizontal = lambda cmd: run('tmux split-window -h "{}"'.format(cmd))
even_vertical = lambda: run('tmux select-layout even-vertical')