Skip to content

Instantly share code, notes, and snippets.

View 9072997's full-sized avatar

Jon Penn 9072997

  • Fayetteville, AR
View GitHub Profile
@9072997
9072997 / shorten.sh
Created March 31, 2023 19:20
a script to recursively shorten all the file names in a directory
#!/bin/bash
# this is a script to recursively shorten all the file names in a directory
function shorten() {
cd "$1"
pwd
# rename all the files in the directory to numbers
# if nessisary, move them to the temp directory to avoid name collisions
i=1
@9072997
9072997 / dns.go
Created January 5, 2023 13:43
OpenDNS EDNS Option 20292
package main
import (
"crypto/md5"
"encoding/binary"
"encoding/hex"
"fmt"
"net"
"github.com/miekg/dns"
@9072997
9072997 / ipecho.go
Created February 1, 2022 13:49
CORS enabled HTTP server that tells users their IP
package main
import (
"net"
"net/http"
)
func main() {
http.HandleFunc("/", func(resp http.ResponseWriter, req *http.Request) {
resp.Header().Set("Access-Control-Allow-Origin", "*")
@9072997
9072997 / main.go
Created January 24, 2021 00:02
Re-produce what I think is a bug in golang.org/x/crypto/ssh
package main
import (
"fmt"
"log"
"net"
"time"
"golang.org/x/crypto/ssh"
)
@9072997
9072997 / cert_pin.rs
Last active January 19, 2021 14:19
ServerCertVerifier for rustls that will accept only a fixed certificate chain
use blake2::{Blake2b, Digest};
pub struct CertHash<'a>(pub &'a str);
impl rustls::ServerCertVerifier for CertHash<'_> {
fn verify_server_cert(
&self,
_roots: &rustls::RootCertStore,
presented_certs: &[rustls::Certificate],
_dns_name: webpki::DNSNameRef<'_>,
@9072997
9072997 / advertiseAirtameAirplay.go
Created October 1, 2020 20:04
Advertise an AirTame AirPlay server via mDNS (in case it is on a diffrent VLAN)
package main
import (
"fmt"
"strings"
"github.com/9072997/jgh"
"github.com/godbus/dbus"
"github.com/holoplot/go-avahi"
)
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQENBFsbXioBCACoC6cuYFjNjnlR6BZazWo08xj3+OYb8BVxgZOFJBhHd0S62ZpD
gxz8OSlstn2d+rGT9ORkk6D6TxurWsT6HStVqmxXSttqhKVghOUeHFmkXy89PiYp
hLhWvSkjBeAy4FlM7f1LxLjbkcoTTvzxVvmW3dBZV6tTOWCAgyKdaasu7zZQ4m7A
1Xx6QWkJ0GxU4y5aJMmTqt5idlm9MsJe1LnT8mxJH+vtOcNQPslNB2AVVapP7yWo
Sy02izlFQyVIusS7VhRCi5Lajx1Fb820yVcYgekv5NEb6xf3xCDLmM/1fuknRatG
eJv9p8E58YenKykTgq4UvWn842RIluwnVCWbABEBAAG0PkpvbmF0aG9uIFBlbm4g
KGJ1c2luZXNzIGNhcmQgaGFyZHdhcmUga2V5KSA8OTA3Mjk5N0BnbWFpbC5jb20+
iQE9BBMBCAAnBQJbG14qAhsDBQkB4TOABQsJCAcCBhUICQoLAgQWAgMBAh4BAheA
@9072997
9072997 / example-mappings.json
Created December 8, 2017 03:54
php script to re-indix an elastic search index (w/ only 1 type) and strip the id field (storeing in in _id)
{
"mappings": {
"my_new_type" : {
"properties" : {
"name" : {
"type" : "string",
"analyzer": "english"
},
"age" : {
"type" : "long"
@9072997
9072997 / reindex.php
Last active February 8, 2018 15:23
Elastissearch reindex-er script in php7
#!/usr/bin/php
<?php
// public domain, requires php curl extensions
// Note: this script can be called with a comma seperated list of
// shards from the source cluster (ex 1,3,4) and it will only pull
// data from those shards. This can allow you to run this script in
// parallell like this:
// For 5 shards, all primary, in 5 threads
// echo $logPrefix . "0 1 2 3 4" | xargs -n 1 -P 100 -- ./reindex.php
@9072997
9072997 / COM-exclusive.c
Last active August 29, 2015 14:07
Gravity Sim
#include <stdio.h>
//#pragma warning(disable: 4996)
#include <stdlib.h>
#include <math.h>
#define NUMPOINTS 3
#define STEPS 5000
//#define G 6.673E-11
#define G 5E-5 //bigger
#define CLOUDDIAMETER 1000
#define MINMASS 1000