It is more complex than it needs to be for most uses because it tries to be as feature-complete as possible.
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
// 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. | |
// |
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
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 |
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
""" 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): |
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
#![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(); |
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
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.""" |
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
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
# 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') |
NewerOlder