Skip to content

Instantly share code, notes, and snippets.

David Pennington Xeoncross

Block or report user

Report or block Xeoncross

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Xeoncross
Xeoncross / dynamodb-setup.sh
Created Nov 20, 2019 — forked from kwilczynski/dynamodb-setup.sh
Something put together quickly to automatically associate Elastic IP address with the current EC2 instance.
View dynamodb-setup.sh
aws dynamodb create-table --region <REGION> --profile <PROFILE> --table-name "<TABLE>" --attribute-definitions "AttributeName=key,AttributeType=S" --key-schema "AttributeName=key,KeyType=HASH" --billing-mode "PAY_PER_REQUEST"
aws dynamodb create-table --region <REGION> --profile <PROFILE> --table-name "<TABLE>" --attribute-definitions "AttributeName=key,AttributeType=S" --key-schema "AttributeName=key,KeyType=HASH" --billing-mode "PROVISIONED" --provisioned-throughput "ReadCapacityUnits=1,WriteCapacityUnits=1"
aws dynamodb update-time-to-live --region <REGION> --profile <PROFILE> --table-name "<TABLE>" --time-to-live-specification "Enabled=true,AttributeName=ttl"
aws dynamodb scan --region <REGION> --profile <PROFILE> --table-name "<TABLE>"
@Xeoncross
Xeoncross / traveling-salesman.php
Created Sep 18, 2012 — forked from tlhunter/traveling-salesman.php
PHP Traveling Salesman Genetic Algorithm
View traveling-salesman.php
<?php
ini_set("error_reporting", E_ALL & ~E_NOTICE);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Genetic Algorithm : TSP : PHP Implementation by Thomas Hunter</title>
<style>
body {
@Xeoncross
Xeoncross / index.php
Created Mar 8, 2012
Tiny, SMTP client in PHP
View index.php
<?php
/*
This is a very tiny proof-of-concept SMTP client. Currently it's over 320 characters (if the var names are compressed). Think you can build one smaller?
*/
ini_set('default_socket_timeout', 3);
$user = 'you@gmail.com';
$pass = '';
$host = 'ssl://smtp.gmail.com';
@Xeoncross
Xeoncross / traverse_node.go
Created Jan 5, 2017
Simple DOM node traversal in golang using a very useful collector/matcher function
View traverse_node.go
package main
import (
"bytes"
"fmt"
"io"
"strings"
"unicode"
"golang.org/x/net/html"
@Xeoncross
Xeoncross / mariadb_generator.sql
Created Nov 11, 2019
Example of writing a MariaDB query to generate 100k records
View mariadb_generator.sql
-- See more at https://stackoverflow.com/a/49446214/99923
INSERT INTO T1 (id, created_on, domain, seen_on)
SELECT one.X, two.X, three.X, two.X
FROM (select seq, seq X from seq_1_to_100000) one
LEFT JOIN (select seq, NOW() - INTERVAL seq MINUTE X from seq_1_to_100000) two ON one.seq = two.seq
LEFT JOIN (select seq, CONCAT(seq,'.',seq) X from seq_1_to_100000) three ON one.seq = three.seq;
@Xeoncross
Xeoncross / smoothing.go
Created Feb 9, 2017
Peak detection "Smoothed z-score algo" (in Golang) from http://stackoverflow.com/a/22640362/99923
View smoothing.go
/*
Settings (the ones below are examples: choose what is best for your data)
set lag to 5; # lag 5 for the smoothing functions
set threshold to 3.5; # 3.5 standard deviations for signal
set influence to 0.5; # between 0 and 1, where 1 is normal influence, 0.5 is half
*/
// ZScore on 16bit WAV samples
func ZScore(samples []int16, lag int, threshold float64, influence float64) (signals []int16) {
//lag := 20
@Xeoncross
Xeoncross / hash_character_sizes.go
Last active Nov 2, 2019
Testing hash digest lengths with different ascii encodings like base64 and base58
View hash_character_sizes.go
package main
import (
"crypto/md5"
"crypto/sha1"
"crypto/sha256"
"crypto/sha512"
"encoding/base64"
"encoding/hex"
"fmt"
@Xeoncross
Xeoncross / int_to_byteslice.go
Last active Nov 2, 2019
Writing a large number of ints to a byte slice is slower when using https://golang.org/pkg/encoding/binary/#Write
View int_to_byteslice.go
package bytewriter
import (
"bytes"
"encoding/binary"
"testing"
)
func BenchmarkBinary(b *testing.B) {
@Xeoncross
Xeoncross / verify.cert.php
Created Nov 17, 2012
Verify that an SSL certificate belongs to the server we are connecting too
View verify.cert.php
<?php
//
// You need a CA cert bundle!
//
// Good
$host = 'www.google.com';
//$host = 'onlinessl.netlock.hu';
// Bad
@Xeoncross
Xeoncross / simple.ses.php
Created Jan 4, 2012
Simple SendEmail wrapper for Amazon SES API (does not support SendRawEmail)
View simple.ses.php
<?php
class SES
{
public $accessKey = NULL;
public $accessKeyID = NULL;
public $host = 'https://email.us-east-1.amazonaws.com/';
public $userAgent = 'Test SES Class / v1.0';
public $data = array();
You can’t perform that action at this time.