Skip to content

Instantly share code, notes, and snippets.

View mbreese's full-sized avatar

Marcus Breese mbreese

  • Indiana University
  • Cincinnati, OH
View GitHub Profile
@mbreese
mbreese / gist:159ab2b04fb05de81e3776827b63a73c
Created July 12, 2023 06:10
Bookmarklet to save web site URLs to a [usememos/memos] site. Replace $$OPENID_URL$$ with your OpenID URL/ID
javascript:function sendurl_to_memos(url,data){let xhr=new XMLHttpRequest();xhr.open("POST", url, true);xhr.setRequestHeader("Content-Type", "application/json");xhr.onreadystatechange=function(){if (xhr.readyState === 4) { if (xhr.status === 200) {alert("Saved!");}else{alert(xhr.readyState+"\n"+xhr.status+" error: "+this.responseText);}}};xhr.send(JSON.stringify(data));};sendurl_to_memos('$$OPENID_URL$$', {"content": document.title+"\n"+window.location.href+"\n#link"});
@mbreese
mbreese / CustomSignalHandler.java
Created February 13, 2024 00:25
Capture signals from Java
package io.compgen.ngsutils.support;
import sun.misc.Signal;
import sun.misc.SignalHandler;
abstract public class CustomSignalHandler implements SignalHandler {
private SignalHandler old = null;
private void setOld(SignalHandler old) {
@mbreese
mbreese / abspath
Created July 30, 2024 22:51
abspath replacement in python
#!/usr/bin/env python3
import os
import sys
if len(sys.argv) == 1:
print(os.path.abspath('.'))
else:
for arg in sys.argv[1:]:
print(os.path.abspath(arg))
@mbreese
mbreese / bcrypt.py
Last active October 10, 2024 14:55
bcrypt
#!/home/mbreese/.local/src/bcrypt-venv/bin/python3
import sys
import bcrypt
def usage():
sys.stderr.write('''\
Encrypting text
Usage: bcrypt {-r} [text]
You can also pipe raw plaintext through stdin (will be stripped unless -r is set!)
@mbreese
mbreese / README.md
Last active February 4, 2025 20:31
Running Postgres as a user account

db.sh

This script will manage a user-run postgres database. The main idea here is to run Postgres on a system where you don't have root access (and don't want root access). If you can not install Postgres through the system (or docker), then this is one way to still be able to use the database, even if you can't start it as a service.

  1. Create a database and initialize it with a user login

    ./db.sh initdb dbname username userpass

  2. Start/stop the database

@mbreese
mbreese / sift_to_vcf.py
Last active February 10, 2025 17:50
Convert SIFT scores to VCF format
#!/usr/bin/env python3
#
# Converts SIFT format files to VCF format for easier annotation lookup
#
# Sift input gz files are tab-delimited gzip compressed files. Coordinates are 1-based, so
# this is a pretty easy conversion.
#
import os
import sys