Skip to content

Instantly share code, notes, and snippets.

View b-b3rn4rd's full-sized avatar

Bernard Baltrusaitis b-b3rn4rd

  • Bendigo Bank
  • Melbourne
View GitHub Profile
@jwage
jwage / SplClassLoader.php
Last active July 23, 2024 18:42
Add MIT license.
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
@loonies
loonies / 1_phpunit-api.md
Last active January 19, 2024 07:34
PHPUnit Cheat Sheet

PHPUnit API reference

  • version 3.6

TODO

Check those constraints:

$this-&gt;anything()
@havvg
havvg / DemoController.php
Created January 10, 2012 13:36
Impersonating a User in Symfony2
<?php
namespace Acme\DemoBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Role\SwitchUserRole;
@griggheo
griggheo / gist:2698152
Created May 14, 2012 23:51
dynamodb batchwriteitem in boto
import os
import sys
import subprocess
import re
import optparse
import boto
dynamodb_conn = boto.connect_dynamodb(aws_access_key_id='MY_ACCESS_KEY_ID', aws_secret_access_key='MY_SECRET_ACCESS_KEY')
table_name = 'mytable'
dynamodb_table = dynamodb_conn.get_table(table_name)
@mattetti
mattetti / multipart_upload.go
Last active July 18, 2024 17:31
Example of doing a multipart upload in Go (golang)
package main
import (
"bytes"
"fmt"
"io"
"log"
"mime/multipart"
"net/http"
"os"
@b-b3rn4rd
b-b3rn4rd / function_v1.php
Last active March 28, 2018 19:06
Convert adjacency list into tree without recursion and second array.
<?php
function array_to_tree(array $array, $parent_id = 0)
{
$array = array_combine(array_column($array, 'id'), array_values($array));
foreach ($array as $k => &$v) {
if (isset($array[$v['parent_id']])) {
$array[$v['parent_id']]['children'][$k] = &$v;
}
<?hh
async function stream_check(resource $stream, string $mode, int $usec): Awaitable<void>
{
$r = $w = $e = null;
do {
if ($mode == "r") {
$r = Vector{$stream};
}
@kachayev
kachayev / concurrency-in-go.md
Last active May 31, 2024 09:34
Channels Are Not Enough or Why Pipelining Is Not That Easy
@grauwoelfchen
grauwoelfchen / log.py
Created October 4, 2015 08:29
Generate concated logs from CloudWatch Logs using bot3 with Python3
import sys
import boto3
import time
from datetime import datetime
profile_name = 'yasuhiro.asaka'
region_name = 'REGION_NAME'
# logs
log_group_name = 'GROUP_NAME'
log_stream_name_prefix = 'PREFIX'
@aaronfay
aaronfay / cloudtrail-elasticsearch-mapping.json
Created March 4, 2016 23:10
Elasticsearch index mapping for CloudTrail logs
{
"mappings": {
"logs": {
"properties": {
"eventVersion": {
"type": "string"
},
"userIdentity": {
"properties": {
"type": {