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 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
SELECT CONCAT( | |
'SELECT ', GROUP_CONCAT(DISTINCT CONCAT(K.CONSTRAINT_NAME, '.', P.COLUMN_NAME, | |
' AS `', P.TABLE_SCHEMA, '.', P.TABLE_NAME, '.', P.COLUMN_NAME, '`') ORDER BY P.ORDINAL_POSITION), ' ', | |
'FROM ', K.TABLE_SCHEMA, '.', K.TABLE_NAME, ' AS ', K.CONSTRAINT_NAME, ' ', | |
'LEFT OUTER JOIN ', K.REFERENCED_TABLE_SCHEMA, '.', K.REFERENCED_TABLE_NAME, ' AS ', K.REFERENCED_TABLE_NAME, ' ', | |
' ON (', GROUP_CONCAT(CONCAT(K.CONSTRAINT_NAME, '.', K.COLUMN_NAME) ORDER BY K.ORDINAL_POSITION), | |
') = (', GROUP_CONCAT(CONCAT(K.REFERENCED_TABLE_NAME, '.', K.REFERENCED_COLUMN_NAME) ORDER BY K.ORDINAL_POSITION), ') ', | |
'WHERE ', K.REFERENCED_TABLE_NAME, '.', K.REFERENCED_COLUMN_NAME, ' IS NULL;' | |
) AS _SQL | |
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE K |
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
if [ -e /etc/apt/sources.list ] && grep -qai '^deb.*squeeze' /etc/apt/sources.list && ! grep -qai squeeze-lts /etc/apt/sources.list; then echo " | |
deb http://http.debian.net/debian/ squeeze-lts main contrib non-free | |
deb-src http://http.debian.net/debian/ squeeze-lts main contrib non-free | |
" >> /etc/apt/sources.list; fi; gpg --keyserver pgpkeys.mit.edu --recv-key 8B48AD6246925553; gpg -a --export 8B48AD6246925553 | apt-key add -; apt-get update; apt-get install bash; vi /etc/apt/sources.list |
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 | |
ini_set('memory_limit', -1); | |
$count = (int)$argv[1]; | |
function fixed_array_search_foreach($stack, $counter, $lookup, $type) { | |
$start = microtime(true); | |
foreach ($stack as $key => $value) { | |
if ($lookup === $value) { |
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 version2integer($version) { | |
$matches = array(); | |
preg_match('/([0-9.]+)/', $version, $matches); | |
if (count($matches) > 1) { | |
$maxSequences = 4; // v12.34.56.78.90 will stop at 78 | |
$matches = explode('.', $matches[1]); | |
$matches = $matches + array(0, 0, 0, 0); |
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 directorySplit($dir, $segmentSize = 2, $maxSegment = 3, $dirSeparator = DIRECTORY_SEPARATOR) | |
{ | |
$segmentedDir = ''; | |
for ($i = 0, $segmentOffset = 0; $i < $maxSegment && strlen($dir) > $segmentOffset; ++$i, $segmentOffset = $segmentSize * $i) { | |
$segment = substr($dir, $segmentOffset, $segmentSize) . $dirSeparator; | |
if (strlen($segment) < $segmentSize) { | |
break; | |
} |
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); | |
}); |
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 | |
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'); |
OlderNewer