Skip to content

Instantly share code, notes, and snippets.

View MidnightLightning's full-sized avatar

Brooks Boyd MidnightLightning

View GitHub Profile
@MidnightLightning
MidnightLightning / keybase.md
Last active September 11, 2019 02:30
Proof of KeyBase identity

Keybase proof

I hereby claim:

  • I am midnightlightning on github.
  • I am midnight (https://keybase.io/midnight) on keybase.
  • I have a public key whose fingerprint is E614 FD43 CA0B 4F67 4BA9 C12A ED5D 1DD5 55C5 F46F

To claim this, I am signing this object:

@MidnightLightning
MidnightLightning / pi.php
Created February 10, 2016 19:42
Compute PI
<?php
echo bcpi(12000);
function bcpi($precision){
bcscale($precision+6);
$a = bcsqrt(2);
$b = 0;
$p = bcadd(2, $a);
$i = 0;
$count = ceil(log($precision+6)/log(2))-1;
@MidnightLightning
MidnightLightning / compress.php
Created February 10, 2016 19:41
Comparison of compress and deflate
<?php echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>PHP compressions</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="content-style-type" content="text/css" />
<style type="text/css">
th { text-align:right; }
.line_number { font-weight:bold; }
@MidnightLightning
MidnightLightning / img.inc.php
Last active April 28, 2017 04:46
Image generating utility functions
<?php
function textImage($msg = "No message") {
$char_size = 3; // Which standard font size?
$char_height = 35; // How tall is a line?
$char_width = 7; // How wide is each character?
// Determine width based on string length
$width = strlen($msg)*$char_width+30;
// Create a blank image to draw on
@MidnightLightning
MidnightLightning / http.inc.php
Created February 10, 2016 19:37
HTTP Transfer class
<?php
/**
* HTTP transfer class
* @author Brooks Boyd
* @version 1.0
* @package simpleHTTP
*/
/**
* Interface used for fetching http data
@MidnightLightning
MidnightLightning / dimetric.php
Created February 10, 2016 19:35
Dimetric SVG creation
<?php
// Create Dimetric SVG image
// Diametric is a parallel projection similar to isometric (30 degrees x 30 degrees grid) which is unequal (15 degrees x 60 degrees).
// To make a unit square, starting at (0,0), on the SVG canvas (Y axis flipped) as the closest point and going clockwise,
// the other points are (-cos(15), -sin(15)), (-cos(15)+cos(60), -sin(15)-sin(60)), (cos(60), -sin(60))
// or, (-0.965925826289068, -0.258819045102521), (-0.465925826289068, -1.12484444888696), (0.50, -0.866025403784439)
$unit_square = new Polygon(
new Point(0,0),
@MidnightLightning
MidnightLightning / stitch.php
Created February 10, 2016 19:33
Crosstitch converter
<?php
// Take an image and convert it into a crosstitch grid
function textImage($msg = "No message") {
$char_size = 3; # Which standard font size?
$char_height = 35; # How tall is a line?
$char_width = 7; # How wide is each character?
// Determine width based on string length
$width = strlen($msg)*$char_width+30;
@MidnightLightning
MidnightLightning / blowfish.inc.php
Last active February 10, 2016 19:32
Blowfish encryption
<?php
/**
* Utilize the Blowfish encryption algorithm without using mcrypt extension
* @package Encryption
* @author Brooks Boyd <[email protected]>
* @version 1.0
*/
/**
* Object for holding encryption key schedule and processing
* @package Encryption
Verifying that +midnight is my Bitcoin username. You can send me #bitcoin here: https://onename.io/midnight
@MidnightLightning
MidnightLightning / package.json
Last active August 29, 2015 14:01
Testing Big Integer performance
{
"name": "mathbuffer-test",
"version": "0.1.0",
"description": "Testing Big Integer implementation performance",
"main": "test.js",
"dependencies": {
"math-buffer": "~0.1.1",
"bigi": "~1.1.0"
},
"author": "Brooks Boyd <[email protected]>"