Skip to content

Instantly share code, notes, and snippets.

// Given an array of visited vertices, where each element represents the parent of the vertex,
// fill the path array with the route between src and dest.
int reconstructShortestPath(Vertex src, Vertex dest, int *visited, int nV, int *path) {
// Based on the suggestion here: https://stackoverflow.com/questions/8379785/how-does-a-breadth-first-search-work-when-looking-for-shortest-path#comment27820665_8379892
// Record the route in a queue.
Queue route = newQueue();
// Backtrack through the visited array, recording each vertex in the queue.
int current = dest;
#!/usr/bin/env bash
# Based on https://medium.com/@chim/ethereum-how-to-setup-a-local-test-node-with-initial-ether-balance-using-geth-974511ce712
# Initialise a local geth testnet with automine
CHAIN_DIRECTORY=~/.testnet;
STARTING_BALANCE="0x5337000000000000000000"
if [ -d "$CHAIN_DIRECTORY" ]; then
rm -r ${CHAIN_DIRECTORY}
/**
* Use this file to configure your truffle project. It's seeded with some
* common settings for different networks and features like migrations,
* compilation and testing. Uncomment the ones you need or modify
* them to suit your project as necessary.
*
* More information about configuration can be found at:
*
* truffleframework.com/docs/advanced/configuration
*
@kdelwat
kdelwat / deprog.py
Created February 12, 2021 20:52
Replace progressive JPEGs in album art with non-progressive JPEGs, recursively
import eyed3
import io
import os
from PIL import Image
def is_progressive(img):
return "progression" in img.info or "progressive" in img.info
def deprogressify(filename):
@kdelwat
kdelwat / Key value storage - first draft
Created June 23, 2021 11:28
Example smart contracts from the Women in Digital workshop. Adapted from the examples at https://docs.soliditylang.org/en/v0.8.6/solidity-by-example.html
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
contract KV {
bytes32[] private reservedKeys;
mapping(bytes32 => string) private values;
constructor(bytes32[] memory _reservedKeys) {
reservedKeys = _reservedKeys;
}