Skip to content

Instantly share code, notes, and snippets.

💣
'); DROP TABLE statuses; --

Ian Littman iansltx

💣
'); DROP TABLE statuses; --
Block or report user

Report or block iansltx

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
@iansltx
iansltx / _safari-iframe-cookie-workaround.md
Last active Jan 21, 2020
Safari iframe cookie workaround
View _safari-iframe-cookie-workaround.md
View chromium-os-docker.md

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 / MultiPartFromStrings.php
Created May 2, 2015
Multipart file uploads in PHP from strings
View MultiPartFromStrings.php
<?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.
@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
}
You can’t perform that action at this time.