Some C examples for quick reference.
// remember the null terminator!
char greet[] = {'H', 'e', 'l', 'l', 'o', '\0'};
int len = sizeof(greet) / sizeof(char);
for (i = 0; i < len; i++) {
class Point: | |
def __init__(self, x, y): | |
self.x = x | |
self.y = y | |
def __str__(self): | |
return 'Stringified Point: ({x}, {y})'.format(x=self.x, y=self.y) | |
def __repr__(self): | |
return 'Representing Point: ({x}, {y})'.format(x=self.x, y=self.y) |
/** | |
Run it at https://repl.it/repls/PunyDisguisedDalmatian | |
*/ | |
class Foo { | |
public void helloFoo() { | |
System.out.println("Hello Foo"); | |
} | |
public Foo getContext() { | |
return this; |
strace ls
strace -e open ls
strace -e trace=open,read,write ls
strace -o ls.txt ls
sudo strace -p pid
strace -t ls
strace -c ls
<?php | |
/** | |
* Single Responsiblity Principle client code | |
*/ | |
// create a book instance, book has no knowledge about rendering | |
$book = new Book(); | |
$book->setTitle("Some Title"); | |
$book->setAuthor("Some Author"); |
<?php | |
class HTMLRenderer implements RendererInterface { | |
public function render($data) { | |
return "<p>{$data}</p>"; | |
} | |
} |
<?php | |
class PlainTextRenderer implements RendererInterface { | |
public function render($data) { | |
return $data; | |
} | |
} |
<?php | |
/** | |
* RendererInterface | |
*/ | |
interface RendererInterface { | |
public function render(); | |
} |
<?php | |
/** | |
* Book Plain Old PHP class | |
*/ | |
class Book { | |
private $title; | |
private $author; | |
private $current_page; | |