I got boot2docker running on xhyve. Here's my startup script:
#!/bin/sh
KERNEL=boot2docker/vmlinuz64
INITRD=boot2docker/initrd.img
CMDLINE='earlyprintk=serial console=ttyS0 acpi=off user=docker'
$ cat catchtest.php | |
<?php | |
interface FooFail {} | |
interface BarFail {} | |
class YesFail extends Exception implements FooFail, BarFail {} | |
class NoFail implements FooFail {} | |
try { throw new YesFail; } | |
catch (FooFail $e) { echo "Caught the foo\n"; } |
<?php | |
/** | |
* BogoBuzz | |
* | |
* FizzBuzz, but randomly | |
*/ | |
$seen = []; | |
while (count($seen) !== 100) { | |
$i = rand(1, 100); |
The dumbest programming challenge
Please write a program that prints the numbers from 1 to 100, but for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers that are multiples of both three and five print "FizzBuzz".
You can do clever things with FizzBuzz. You can write it recursively, or use a stack. You can do better math, remembering that the LCM of three and five is fifteen. But here's the thing about FizzBuzz. Programmers get nervous in interviews and they forget the basics. They don't forget math, or the syntax of a for
loop. I mean they forget how to deconstruct a programming problem. FizzBuzz has just enough crap in it that trying to write it in one step is foolish. Break the program down into its discrete functions.
#!/bin/bash | |
brewUses() { | |
brew list | | |
xargs -n1 -P6 bash -c 'echo "$1" $(brew uses --installed "$1")' _ | | |
awk '{ | |
printf "%02d\033[1m %s \033[0m", NR, $1 | |
for (i=2; i<NF; ++i) { | |
printf "\033[34mUSED BY:" | |
printf "\033[0m \033[4m%s", $i |
#!/bin/bash | |
# Testing what happens with storage with deleted containers | |
tcsetup() { | |
rm -rf /root/fstest | |
mkdir -p /root/fstest | |
} | |
tcinfo() { | |
du -s /mnt/sda1/var/lib/docker |
>>> x = 1 | |
>>> def inc(x): x+=1 | |
... | |
>>> inc(x) | |
>>> x | |
1 | |
>>> inc(x) | |
>>> x | |
1 |
What are we talking about?
How does this Python function work?
def parenthesesMatch(par):
lst = []
push="<({["
pop=">)}]"
for l in par :
<?php | |
class A { | |
public function A1 () { | |
return $this->A2(); | |
} | |
protected function A2() { | |
return __METHOD__; | |
} | |
} |
<?php | |
/** | |
* What if we use an IIFE to guarantee scope control | |
* as well as aliasing and type hints for setup? | |
*/ | |
// Standard setup script: | |
/** | |
* There's nothing really wrong with this, but you may wonder why alias $this to $installer. | |
* Also, what happens to the $entity var when the script is done? |