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 / fib.php
Last active December 19, 2015 10:38
This is an obfuscated command line php program to generate numbers from the fibonacci sequence. The first argument is the starting point and the last is the ending point for the generated numbers, so for example "php fib.php 1 100" would generate the first 100 numbers of the fibonacci sequence. I challenge you to determine the twist in the logic…
<?php $c[1][1]='1';function p($r,$p){global $c;if(isset($c[$r][$p]))$r=
$c[$r][$p];elseif($p==1)$r=$c[$r][$p]=p($r-1,$p);elseif($p==$r)$r=$c[$r]
[$p]=p($r-1,$p-1);else$r=$c[$r][$p]=bcadd(p($r-1,$p-1),p($r-1,$p));
return $r;}function f($s){$l=ceil($s/2);$p=1;$t='0';for($i=1;$i<=$l;$i++
)$t=bcadd($t,p($s--,$p++));return $t;}for($i=$argv[1];$i<=$argv[2];$i++)
echo f($i).' ';?>
@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
@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 / 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"
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQENBFsbXioBCACoC6cuYFjNjnlR6BZazWo08xj3+OYb8BVxgZOFJBhHd0S62ZpD
gxz8OSlstn2d+rGT9ORkk6D6TxurWsT6HStVqmxXSttqhKVghOUeHFmkXy89PiYp
hLhWvSkjBeAy4FlM7f1LxLjbkcoTTvzxVvmW3dBZV6tTOWCAgyKdaasu7zZQ4m7A
1Xx6QWkJ0GxU4y5aJMmTqt5idlm9MsJe1LnT8mxJH+vtOcNQPslNB2AVVapP7yWo
Sy02izlFQyVIusS7VhRCi5Lajx1Fb820yVcYgekv5NEb6xf3xCDLmM/1fuknRatG
eJv9p8E58YenKykTgq4UvWn842RIluwnVCWbABEBAAG0PkpvbmF0aG9uIFBlbm4g
KGJ1c2luZXNzIGNhcmQgaGFyZHdhcmUga2V5KSA8OTA3Mjk5N0BnbWFpbC5jb20+
iQE9BBMBCAAnBQJbG14qAhsDBQkB4TOABQsJCAcCBhUICQoLAgQWAgMBAh4BAheA
@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"
)
@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 / 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 / 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 / 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"