Skip to content

Instantly share code, notes, and snippets.

// A simple wrapper.
//
// In Java:
//
// static String getString(String key);
//
// Calls the C++ function:
//
// C++: std::string openmpt::string::get(std::string &key);
//
package org.example
import java.io.File
import java.util.*
typealias ResultType = String
interface Processor<T : Any> {
fun getType(): Class<T>
package org.example
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import java.util.concurrent.Executors
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine
@mRB0
mRB0 / ssh-config
Created October 23, 2020 19:04
SSH config for easier access to a remote host via ssh proxy, with meaningful hostnames
# Some ~/.ssh/config things I've been experimenting with.
#
# I need to ssh to a host (bastion) on a public IP address, and then proxy
# through that host to reach another host (inner, private IP 10.0.0.53).
#
# This method allows me to:
#
# 1. Keep my private ssh key local (not stored on bastion)
# 2. Avoid using agent forwarding (for strict control of how my key
# can be used)
extern crate cairo;
use std::fs::File;
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
let surface = cairo::ImageSurface::create(cairo::Format::ARgb32, 640, 480)?;
let context = cairo::Context::new(&surface); // Borrows `surface` (immutable!)
if [[ ! -z $SSH_AUTH_SOCK ]]; then
# echo "zshrc.d/ssh-agent: warning: SSH_AUTH_SOCK is set; skipping agent setup"
else
eval $(ssh-agent -s)
trap 'test -n "$SSH_AGENT_PID" && eval `/usr/bin/ssh-agent -k`' 0
fi
@mRB0
mRB0 / decrypt.py
Last active August 27, 2018 12:36
Jython scripts to encrypt and decrypt symmetrically using OpenPGP format using BouncyCastle
#!/usr/bin/env jython
import sys
sys.path.append('bcprov-jdk15on-160.jar')
sys.path.append('bcpg-jdk15on-160.jar')
import itertools
from org.python.core.io import StreamIO
private val loadJob: Job? = null
fun onClick() {
loadJob?.cancel()
loadJob = async(UI) {
val image = loadImage() // suspend fun loadImage
imageView.image = image
}
}
@mRB0
mRB0 / gitconfig
Created May 11, 2017 13:21
git alias for ahead-behind count
[alias]
aheadbehind = !"f() { against=${1:-master}; git rev-list --left-right --count $against...HEAD | awk '{print \"You are \" $2 \" commit(s) ahead of '$against' and \" $1 \" commit(s) behind\"}'; }; f"
@mRB0
mRB0 / share.bash
Last active March 18, 2017 16:49
A shell script replacement for the Dropbox public folder, using S3 for storage and serving.
#!/usr/bin/env bash
#
# Usage:
#
# share.bash file1 file2 file3 ...
#
#
# Simple setup: