This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Because mysqlimport doesn't allow to append/prepend | |
# custom statements and we need to disable the foreign | |
# keys constraint which does not exist yet | |
if [ "$#" -lt 2 ]; then | |
printf "usage: %s database path_to_backup\n" $0 | |
exit -1; | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Shorty\FirstBundle\Repository; | |
interface ShortenedUrlRepositoryInterface | |
{ | |
public function findLatestShortenedUrl($itemCount); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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'])) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.myTransform(@argument : none) { | |
-webkit-transform: ~"@argument"(10px); | |
-moz-transform: ~"-moz-@{argument}"(10px); | |
etc.. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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)); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function utf8_urldecode($str) { | |
$str = preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\1;",urldecode($str)); | |
return html_entity_decode($str,null,'UTF-8');; | |
} | |
// Main | |
$options = getopt('de'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$options = getopt('i:c:'); | |
if (!isset($options['i']) && !isset($options['c'])) { | |
printf("Usage: %s -i iterations -c count\n", ltrim($argv[0], './')); | |
exit(0); | |
} | |
$iterations = $options['i']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** @link http://madskristensen.net/post/A-shorter-and-URL-friendly-GUID.aspx */ | |
function fromBase64($input) { | |
$segments = unpack('C*', base64_decode(str_replace(array('_', '-'), array('/', '+'), $input))); | |
array_walk($segments, function(&$segment, $key) { | |
$segment = dechex($segment); | |
}); |