Skip to content

Instantly share code, notes, and snippets.

@jlowry
jlowry / little_type_trick.rs
Created October 8, 2020 20:34
Genna's efficient tuple lookups with some unsafe-but-not-really memory manipulation.
// It copies only the string headers (no more expensive than two &str copies)
// It's unsafe but only a little type trick to make the HashMap work properly with tuple keys
let owned: ManuallyDrop<(String, String)> =
ManuallyDrop::new(unsafe {(mem::read(my_ref.0), mem::read(my_ref.1))});
@jlowry
jlowry / main.rs
Created July 28, 2020 17:27
Rough Idea for iteration over hierarchy
use nalgebra::*;
use std::hash::Hash;
struct Node {
similarity: Similarity3<f32>,
children: u32,
}
fn main() {
let mut hierarchy: Vec<Node> = vec![
@jlowry
jlowry / repo2ssh.sh
Last active April 6, 2020 19:19
Convert GitHub repo URLs from HTTPS to SSH
#!/bin/bash
# Call it with directories to recursively change GitHub URLs found in .git/config and .gitmodules
# Usage:
# sh repo2ssh.sh <directory> [<directory> ...]
for f in "$@"
do
find "$f" \( -path '*/.git/config' -o -path '*/.gitmodules' \) \
-type f -print0 | xargs -0 -t \
@jlowry
jlowry / docker-compose.yml
Created June 1, 2017 08:50
Docker compose file for Drupal
version: "2"
services:
mariadb:
image: wodby/mariadb:10.1-2.1.0
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: drupal
MYSQL_USER: drupal
MYSQL_PASSWORD: drupal

Keybase proof

I hereby claim:

  • I am jlowry on github.
  • I am jlowry (https://keybase.io/jlowry) on keybase.
  • I have a public key ASCC2U4D9NQQkry0cjNPIhUi9T7wjKyWfgtR9zJVoQoYqQo

To claim this, I am signing this object: