Skip to content

Instantly share code, notes, and snippets.

@borisguery
borisguery / formatbytes.php
Created December 20, 2012 14:16
format bytes to the best fitted unit
#!/usr/bin/env php
<?php
function formatBytes($bytes, $precision = 2) {
$units = array('B', 'KB', 'MB', 'GB', 'TB');
$bytes = max($bytes, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
$pow = min($pow, count($units) - 1);
$bytes /= (1 << (10 * $pow));
@borisguery
borisguery / gist:5908055
Last active December 19, 2015 05:59 — forked from armetiz/gist:5908044
.myTransform(@argument : none) {
-webkit-transform: ~"@argument"(10px);
-moz-transform: ~"-moz-@{argument}"(10px);
etc..
}
@borisguery
borisguery / upload_parameters.rb
Created July 9, 2013 09:58
Upload parameters according to the current stage in capistrano
task :upload_parameters do
desc 'Upload stage parameters'
capifony_pretty_print '--> Uploading stage parameters'
origin_file = "app/config/parameters.#{fetch(:stage)}.yml"
destination_file = deploy_to + '/' + shared_dir + '/app/config/parameters.yml'
run "sh -c 'if [ ! -d #{File.dirname(destination_file)} ] ; then mkdir -p #{File.dirname(destination_file)}; fi'"
top.upload(origin_file, destination_file)
#!/usr/bin/env bash
VERBOSE=1
IPS_FILE="/tmp/elb_ips"
BACKEND_VCL="/etc/varnish/backend.vcl"
# Does not keep newlines, but it's ok
read -r -d '' BACKEND_TEMPLATE <<'EOF'
backend internal_elb_{ELB_NUM} {
.host = "{ELB_IP}";
.port = "80";
#!/usr/bin/env php
<?php
require __DIR__.'/../vendor/autoload.php';
use Aws\S3\S3Client;
$options = getopt('a:s:d:b:c:vh');
if (isset($options['h'])) {
PHPUnit 5.1.4 by Sebastian Bergmann and contributors.
Bgy\Tests\Commanding\ConventionalCommandHandler
[x] Handle method properly handles command
Bgy\Tests\EventStore\OptimisticConcurrencyPolicy
[x] If expected revision is any it should not throw any exception
[x] If no stream or empty is expected but actual stream is not, optimistic concurrency should failed
[x] If a revision is expected but the stream does not exist, optimistic concurrency should failed
[x] If a revision is expected but different from the actual, optimistic concurrency should failed
@borisguery
borisguery / wssetoken.php
Created September 27, 2012 08:19
WsseToken generator for curl
#!/usr/bin/env php
<?php
function wsse_header($username, $password) {
$nonce = hash_hmac('sha512', uniqid(null, true), uniqid(), true);
$created = new DateTime('now', new DateTimezone('UTC'));
$created = $created->format(DateTime::ISO8601);
$digest = sha1($nonce.$created.$password, true);
return sprintf(
#!/bin/bash
# Author: Boris Guéry <guery.b@gmail.com>
usage() {
cat <<EOF
usage: $0 <command> [-h] [-y] [-vvv] [-d] [<args>]
Currently supported commands are:
push Push current database data to S3
pull Download latest database snapshot and remove existing one
EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.0</real>