Skip to content

Instantly share code, notes, and snippets.

const uploader = new S3UploadStream(s3, {
Bucket: bucketName,
ContentType: contentType,
Key: key,
})
stream.pipe(uploader)
return new Promise((resolve, reject) => {
uploader.on('uploadFinished', (result: CompleteMultipartUploadCommandOutput, fileSizeBytes: number) => {
@kbanman
kbanman / modifier.ordinal.php
Created August 1, 2014 22:03
Smarty ordinal modifier plugin
<?php
/**
* Gets the ordinal for a number
*
* @param integer $number
* @param string $format Format to render the number and ordinal
* @return string
*/
function smarty_modifier_ordinal($number, $format = '%i%s')
#!/bin/bash
LOGFILE=/tmp/app-init.log
BINPATH=/usr/bin
GMPATH=/usr/local/bin/gm
WKHTMLPATH="$BINPATH/wkhtmltopdf"
function log {
echo "[$(date "+%Y-%m-%d %T")] $1" >> $LOGFILE
@kbanman
kbanman / gist:7192432
Created October 28, 2013 07:01
Demo of strange behaviour in KnexJS when inserting into a table whose primary key is a string
// Knex 0.4.11
var Knex = require('knex');
var Q = require('q');
var DB = Knex.initialize({
client: 'mysql',
connection: {
adapter: 'mysql',
database: 'temp',
user: 'root',
var Knex = require('knex');
var _ = require('underscore');
Knex.Initialize({
client: 'mysql',
connection: {
host: 'localhost',
user: '',
database: ''
}
@kbanman
kbanman / nginx.conf
Last active December 14, 2015 07:59
nginx base config
user _www;
worker_processes 1;
#error_log /var/log/nginx.errors;
error_log /var/log/nginx.errors notice;
#error_log /var/log/nginx.errors info;
pid /usr/local/var/run/nginx.pid;
@kbanman
kbanman / dd.php
Last active December 12, 2015 08:18
Rich alternative to var_dump()
<?php
/*
* Pretty dump and die
*/
function dd($var, $depth=0)
{
static $test;
if ($depth > 5) {
return 'TOO MANY TURTLES!';
@kbanman
kbanman / adduser.php
Created September 21, 2012 22:16
adduser implementation for OSX
#!/usr/bin/env php
<?php
function prompt($msg, $default = false)
{
if ($default !== false)
{
$msg .= ' ['.$default.']';
}
echo $msg.': ';
@kbanman
kbanman / restrish
Created September 13, 2012 00:02
Restrish: A restricted shell written in PHP. Allows whitelisting commands.
#!/usr/bin/env php
<?php
$allow = array('cd', 'ls');
$prompt = 'restrish';
$warning = 'Command not allowed: %s';
/****** TODO LIST
- Better parsing of command delimiters (ignore quoted delimiters)
- Use readline for command history
@kbanman
kbanman / gist:3153921
Created July 20, 2012 23:55
Modest documentation WIP

Modest

Base model for the laravel PHP Framework for use with the Squi UI generation bundle.

Installation

Use the Laravel artisan CLI tool to download the bundle: