Directory structure:
src/
Foo.php
Foo/
Exception.php
Excecption/
Unauthorized.php
NotFound.php
Method.php
<? | |
foreach($filters as $pos => $filter) { | |
if( ! $filter instanceof Filter\FilterInterface ) { | |
throw new \InvalidArgumentException( | |
sprintf('Argument 3 passed to %s::%s must be an array of instances of %s, %s given for index %d', | |
__CLASS__, __FUNCTION__, 'Filter\FilterInterface', get_class($filter), $pos) | |
); | |
} | |
} |
Directory structure:
src/
Foo.php
Foo/
Exception.php
Excecption/
Unauthorized.php
NotFound.php
Method.php
<?php | |
// supplied encoding function | |
function stupidEncode($input, $key) { | |
$k = $key; | |
$r = $input; | |
$l = strlen($r); | |
$e = ""; | |
for($i=0; $i < $l; $i++){ |
Script: | |
ARGS_COMMAND='find logs -type f ! -size 0 -exec grep -l "Broken pipe" {} \;' | |
parallel -j $MAXJOBS -i bash -c $EXEC_COMMAND -- $($ARGS_COMMAND) | |
Bash -x output: | |
++ find logs -type f '!' -size 0 -exec grep -l '"Broken' 'pipe"' '{}' '\;' | |
find: missing argument to `-exec' |
// a complex iterator | |
function gen() { | |
$pagesize = 50; | |
while( $items = $someapi->paginated_operation($pagesize) ) { | |
foreach( $items as $item ) { | |
yield $item; | |
} | |
} | |
} |
require 'mysql2' | |
my = Mysql2::Client.new(:host => 'localhost', :username => 'root', :database=>'test') | |
stmt = my.prepare('INSERT INTO user (salt, password) VALUES(?,?);') | |
salt = "1a7v95zj1xa1l26g80meeaplc7294dp" | |
hashed = "4542511a19a5b18fd6801653ddc97b6e6ef3e855f4736720d791c4f4eed78957c0b5906921725a3ad0d8e98cf6722243f64e552382a37eb839f204d4fe6770ae" | |
stmt.execute(salt, hash) | |
# woops, that should be 'hashed', not 'hash'. |
<?php | |
$cur = $seconds; | |
for( $i = count( $this->multipliers ) - 1; $i >= 0; $i -- ) { | |
$ps = $this->periodSize( $i ); | |
$parts[] = (int) floor( $cur / $ps ); | |
$cur -= $cur - ($cur % $ps); | |
} | |
var_dump($parts); |
In Metrics: | |
host-*.CPUload.{load1,load5,load15} | |
Function: | |
averageSeriesWithWildcards($in, 1) | |
Out Metrics, Expected: | |
host-*.CPUload.load1, | |
host-*.CPUload.load5, | |
host-*.CPUload.load15 | |
[exactly 3 series] | |
Out Metrics, Actual: |
# I've seen a _lot_ of code written to make bash prompts that are just _OK_, | |
# but there's no reason to invoke python/ruby/etc and parse git output since | |
# git ships with a pretty outstanding utility. | |
# 1. Load the library that already ships with git | |
source /usr/share/doc/${git_doc_path_here}/contrib/completion/git-prompt.sh | |
# 2. Set your options | |
export GIT_PS1_SHOWDIRTYSTATE=1 | |
export GIT_PS1_SHOWSTASHSTATE=1 |