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 / transform.php
Created August 12, 2014 04:25
Toggl CSV -> grouped by description and project + decimal hours QDPA
<?php
$filename = $argv[1];
if (!file_exists($filename))
die("file not found\n");
$rows = explode("\n", str_replace(["\r\n", "\r"], "\n", trim(file_get_contents($filename))));
$headers = str_getcsv(array_shift($rows));
$data = array_map(function($row) use ($headers) {return array_combine($headers, str_getcsv($row));}, $rows);
usort($data, function($a, $b) {return strtotime($a['Start date']) > strtotime($b['Start date']) ? 1 : -1;});
@iansltx
iansltx / MyAction.php
Created July 18, 2014 23:42
On-construct ADR content type negotiation
<?php
class MyAction
{
protected $request;
protected $responder;
public function __construct(Aura\Web\Request $request, ResponderInterface $responder) {
// you'd inject other stuff here normally, but let's assume that this is extended elsewhere
$this->request = $request;
@iansltx
iansltx / triples.py
Last active August 29, 2015 14:03
Get a list of all primitive Pythagorean triples with hypotenuse <= Nmax, one per line
# pass the MB of RAM you want to use as your argument
# Nmax = 10,000 * RAM_in_MB; CPU time on an EC2 r3.8xlarge is 60s/1M Nmax
# adapted from http://stackoverflow.com/a/8263898/2476827
import sys
from numpy import mat, array
def gen_pythagorean_triples(max):
u = mat(' 1 2 2; -2 -1 -2; 2 2 3')
a = mat(' 1 2 2; 2 1 2; 2 2 3')
d = mat('-1 -2 -2; 2 1 2; 2 2 3')
<?php
class MyQuery {
protected function buildCollectionQuery($is_count_query = false) {
$qs = $is_count_query ? $this->baseCountQS : $this->baseCollectionQS;
$qsParams = [''];
if ($this->showInactive === false) {
$qs .= " && u.userStatus = 'active'";
}