Skip to content

Instantly share code, notes, and snippets.

View gmporter's full-sized avatar

George Porter gmporter

View GitHub Profile
@gmporter
gmporter / gist:97348b9fc99cdc269bd5f9eb59dfa247
Created March 26, 2023 14:34
Golang FA firehose interface
// The ChatGPT prompt that generated this code:
//
// "Write a Go program that interacts with the Flightaware API
// to determine which planes are currently within 10 miles
// of the Montgomery-Gibbs Executive Airport in San Diego, CA."
package main
import (
"encoding/json"
gmporter@tradervics samples % ./gensort -randseed 1 file1.dat 2048
Initializing the random seed to 1
Requested 2048 (= 2048) bytes
Increasing size to 2100 to be divisible by 100
gmporter@tradervics samples % ./SurfstoreBlockLocatorExec -downServers 1,2,3,4,5,6,7,8,9 10 128 file1.dat
2022/11/30 10:39:08 Total number of blockStore servers: 10
2022/11/30 10:39:08 Block size: 128
2022/11/30 10:39:08 Processing input data filename: file1.dat
2022/11/30 10:39:08 Server 1 is in a failed state
2022/11/30 10:39:08 Server 2 is in a failed state
gmporter@tradervics samples % ./gensort -randseed 1 file1.dat 2048
Initializing the random seed to 1
Requested 2048 (= 2048) bytes
Increasing size to 2100 to be divisible by 100
gmporter@tradervics samples % ./SurfstoreBlockLocatorExec -downServers 4 10 128 file1.dat
2022/11/30 10:37:07 Total number of blockStore servers: 10
2022/11/30 10:37:07 Block size: 128
2022/11/30 10:37:07 Processing input data filename: file1.dat
2022/11/30 10:37:07 Server 4 is in a failed state
{{e366a3d6584b5662c2f23eb8a9b8fbe8f61868f0fa87e57bae3f1d0124ff9097,8},{ba6af9d20d84fb9d9e58c57c3b6a68c4b5a603f72e63ef264c589ca05e51c9a2,7},{acbb2562f3b39632f984b61c4c2bff8cdfa2afff72d1310a02c6da12140a37bc,5},{70603344fcd5fb4798e88553c60d9047a902c090d0de9c4d2c491ebea194980d,2},{14f912aa47907f5515ef1b088c7ba35168c4e45388c9904d128e39fa58d28409,8},{0729d0b4ef3652a5d9f6720bb3408e5a337ec53d33602e9ce6394412ea8f4bb4,8},{6f043f05a771e1147145e25d774405c496c4635fc16f680b8caa37b94fcbc542,2},{cbc28b9ea460bda07b01ec1ff9ee0d9d89b2a1bcfcbd332ab916fe70859
gmporter@tradervics samples % ./gensort -randseed 1 file1.dat 2048
Initializing the random seed to 1
Requested 2048 (= 2048) bytes
Increasing size to 2100 to be divisible by 100
gmporter@tradervics samples % ./SurfstoreBlockLocatorExec 10 128 file1.dat
2022/11/30 10:35:47 Total number of blockStore servers: 10
2022/11/30 10:35:47 Block size: 128
2022/11/30 10:35:47 Processing input data filename: file1.dat
2022/11/30 10:35:47 No servers are in a failed state
{{e366a3d6584b5662c2f23eb8a9b8fbe8f61868f0fa87e57bae3f1d0124ff9097,4},{ba6af9d20d84fb9d9e58c57c3b6a68c4b5a603f72e63ef264c589ca05e51c9a2,7},{acbb2562f3b39632f984b61c4c2bff8cdfa2afff72d1310a02c6da12140a37bc,5},{70603344fcd5fb4798e88553c60d9047a902c090d0de9c4d2c491ebea194980d,2},{14f912aa47907f5515ef1b088c7ba35168c4e45388c9904d128e39fa58d28409,8},{0729d0b4ef3652a5d9f6720bb3408e5a337ec53d33602e9ce6394412ea8f4bb4,8},{6f043f05a771e1147145e25d774405c496c4635fc16f680b8caa37b94fcbc542,2},{cbc28b9ea460bda07b01ec1ff9ee0d9d89b2a1bcfcbd332ab916fe7085940781,0},{6ee
gmporter@tradervics samples % ./gensort -randseed 2 file1.dat 100
Initializing the random seed to 2
Requested 100 (= 100) bytes
gmporter@tradervics samples % ./SurfstoreBlockLocatorExec 1 4096 file1.dat
2022/11/30 10:34:17 Total number of blockStore servers: 1
2022/11/30 10:34:17 Block size: 4096
2022/11/30 10:34:17 Processing input data filename: file1.dat
2022/11/30 10:34:17 No servers are in a failed state
{{b1e08df1902ae3e484a01009d10b6f3bad778ccf0ff022b82dd988ec9a5e2a12,0}}
gmporter@tradervics samples % ./SurfstoreBlockLocatorExec 1 25 file1.dat
gmporter@tradervics samples % ./gensort -randseed 1 file1.dat 100
Initializing the random seed to 1
Requested 100 (= 100) bytes
gmporter@tradervics samples % ./SurfstoreBlockLocatorExec 1 4096 file1.dat
2022/11/30 10:32:02 Total number of blockStore servers: 1
2022/11/30 10:32:02 Block size: 4096
2022/11/30 10:32:02 Processing input data filename: file1.dat
2022/11/30 10:32:02 No servers are in a failed state
{{f06ecd58bd5414ccf81eebd167e95a1f43c09d564ffd526d56d7cc91a57ce405,0}}
@gmporter
gmporter / gist:135ee0860bd7501cf9a0a608342db75d
Last active September 7, 2020 16:47
Git on Dropbox race conditions
www/themes $ git clone https://github.com/vimux/mainroad
Cloning into 'mainroad'...
error: could not write config file /mnt/c/Users/gmporter/Dropbox (UCSD SysNet)/UCSD/Teaching/Courses/CSE124/CSE124-FA20/cse-x24-staff/www/themes/mainroad/.git/config: Permission denied
fatal: could not set 'core.ignorecase' to 'true'
www/themes $ set -o vi
www/themes $ git clone https://github.com/vimux/mainroad
fatal: destination path 'mainroad' already exists and is not an empty directory.
www/themes$ rm -rf mainroad/
rm: cannot remove 'mainroad/.git/refs': Permission denied
www/themes $ rm -rf mainroad/
@gmporter
gmporter / gist:a41b6f1be571ba35ac562307ca1c761e
Created February 7, 2020 19:20
Short example of using the PicoSHA library
#include <iostream>
#include "picosha2.h"
using namespace std;
int main(int argc, char* argv[])
{
vector<unsigned char> block;
for (int i = 0; i < 4096; i++)
package surfstore;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
import com.google.protobuf.ByteString;