Skip to content

Instantly share code, notes, and snippets.

View iansltx's full-sized avatar
💣
'); DROP TABLE statuses; --

Ian Littman iansltx

💣
'); DROP TABLE statuses; --
View GitHub Profile
@iansltx
iansltx / _safari-iframe-cookie-workaround.md
Last active April 7, 2024 15:44
Safari iframe cookie workaround
@iansltx
iansltx / MultiPartFromStrings.php
Created May 2, 2015 03:31
Multipart file uploads in PHP from strings
<?php
/**
* PHP's curl extension won't let you pass in strings as multipart file upload bodies; you
* have to direct it at an existing file (either with deprecated @ syntax or the CURLFile
* type). You can use php://temp to get around this for one file, but if you want to upload
* multiple files then you've got a bit more work.
*
* This function manually constructs the multipart request body from strings and injects it
* into the supplied curl handle, with no need to touch the file system.

Chromium OS ft. Docker

Chromium OS is cool. Chromium OS with crouton is cooler. Chromium OS with Docker is even cooler. This is specifically a guide for the HP Chromebook 13 G1 (aka HP Spyder Chromebook), but I can't think of any reason it wouldn't work with other devices. The Chromebook Pixel 2 (2015), for example...as you'll notice, the guide this was forked from assumed that machine.

  1. Create a build environment
  2. Customize the kernel
  3. Build Chromium OS
  4. Flash Chromium OS to USB
  5. Install Chromium OS
@iansltx
iansltx / Container.php
Last active May 16, 2023 22:19
Dependency Injection Sample Code - 2023
<?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]); }
}
@iansltx
iansltx / booster.php
Created November 28, 2022 05:11
Post Booster
<?php
// The script will keep its place based on a file called min_id, which should contain
// the ID of the post after which we should start boosting. If we don't specify an ID,
// we'll grab the latest 40 posts and boost them, writing the min_id file as we go
// through the list. So if you don't want to potentially duplicate boosts, make sure
// a status ID is in that file.
// To run this script, you'll need to install PHP. You can do that on an Ubuntu 22.04 box by running
// sudo apt install php-cli
@iansltx
iansltx / jtt.php
Last active April 29, 2021 06:07
Quick CLI for adding work log times in JIRA
#!/usr/bin/env php
<?php
if ($argc < 3) {
die("Usage: ./jtt.php ISSUE-1 30m optional comment here\n");
}
$username = 'EMAIL_GOES_HERE';
$token = 'API_KEY_HERE'; // see https://developer.atlassian.com/cloud/jira/platform/jira-rest-api-basic-authentication/
$team = 'TEAM_NAME_HERE';
@iansltx
iansltx / property-bench.php
Created April 10, 2020 21:19
Microbenchmark for typed property vs. setter
<?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 / 2020-08-23 17:44.txt
Created August 23, 2020 22:44
Nighthawk M1 Austin AT&T Field Test
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 / UuidModel.php
Created August 1, 2019 20:49
UUID Model
<?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
{
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class ModifyExistingEnum extends Migration
{
public function up()
{