Skip to content

Instantly share code, notes, and snippets.

Avatar
💣
'); DROP TABLE statuses; --

Ian Littman iansltx

💣
'); DROP TABLE statuses; --
View GitHub Profile
@iansltx
iansltx / 2020-08-23 17:44.txt
Created Aug 23, 2020
Nighthawk M1 Austin AT&T Field Test
View 2020-08-23 17:44.txt
ian@fiora:~/Desktop/platform-tools$ telnet 192.168.1.1 5510
Trying 192.168.1.1...
Connected to 192.168.1.1.
Escape character is '^]'.
AT!GSTATUS?
AT!GSTATUS?
!GSTATUS:
Current Time: 1035 Mode: ONLINE
System mode: LTE PS state: Attached
EMM state: Registered Normal Service
@iansltx
iansltx / property-bench.php
Created Apr 10, 2020
Microbenchmark for typed property vs. setter
View property-bench.php
<?php
// Compares the performance of a trivial typehinted setter with a public typed property
define('ITERATIONS', 1_000_000);
ini_set('memory_limit', '384M');
$arrays = [];
echo "Building data...";
@iansltx
iansltx / Container.php
Last active Sep 12, 2019
Dependency Injection Sample Code - 2019
View Container.php
<?php
class Container implements Psr\Container\ContainerInterface {
protected $s = [];
function __set($k, $c) { $this->s[$k]=$c; }
function __get($k) { return $this->s[$k]($this); }
function get($k) { return $this->s[$k]($this); }
function has($k) { return isset($s[$k]); }
}
View UuidModel.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Ramsey\Uuid\Uuid;
// Abstract class using inheritance rather than composition to avoid trait override errors
abstract class UuidModel extends Model
{
View ModifyExistingEnum.php
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class ModifyExistingEnum extends Migration
{
public function up()
{
View More optimized load test result
/\ |‾‾| /‾‾/ /‾/
/\ / \ | |_/ / / /
/ \/ \ | | / ‾‾\
/ \ | |‾\ \ | (_) |
/ __________ \ |__| \__\ \___/ .io
execution: local
output: influxdb=http://influxdb:8086/k6 (http://influxdb:8086)
script: /scripts/base.js
View getLines.php
<?php // works on single-file non-ZIp64 zip files compressed with deflate (AKA a common case), licensed MIT
function getLinesFromZippedCSVfromURL(string $url) : \Generator
{
$stream = fopen($url, 'rb');
fread($stream, 4 + 2 + 2 + 2 + 2 + 2 + 4); // skip up to compressed size
// bindec() was doing weird things, hence converting through hex first
// sttrev() to match endian-ness to expectations; zip file values are little-endian
@iansltx
iansltx / talks.php
Created Apr 30, 2019
List of everyone who has submitted Joind.in talk comments for a given event
View talks.php
<?php
$eventId = 7021;
#$eventId = 7045; #Yorkshire, for testing
$comments = json_decode(file_get_contents('https://api.joind.in/v2.1/events/'.$eventId.'/talk_comments?resultsperpage=9999'), true)['comments'];
$users = [];
foreach ($comments as $comment) {
@iansltx
iansltx / With.php
Created Feb 27, 2019
Simulating Python's With keyword with foreach and a trait in PHP
View With.php
<?php // Pretty sure this doesn't clean up on exceptions, so keep that in mind
trait With
{
abstract protected function enter(...$args);
protected function exit($built, ...$initArgs)
{
// override this if needed
}
@iansltx
iansltx / distributions.js
Created Jul 28, 2018
AndreasMadsen/distributions browserified
View distributions.js
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.distributions = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
exports.Normal = require('./distributions/normal.js');
exports.Studentt = require('./distributions/studentt.js');
exports.Uniform = require('./distribut