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 python3 | |
# -*- coding: utf-8 -*- | |
import inspect | |
import functools | |
class InvalidObjectError(ValueError): | |
""" | |
Raised when the service locator cannot create a class |
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
{ | |
"require": { | |
"silex/silex": "~1.2", | |
"twig/twig": "~1.16", | |
"symfony/form": "~2.6", | |
"symfony/validator": "~2.6", | |
"symfony/config": "~2.6", | |
"symfony/translation": "~2.6", | |
"symfony/twig-bridge": "~2.6" | |
} |
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 gen($x) | |
{ | |
if (!is_int($x)) { | |
throw new \InvalidArgumentException; | |
} | |
foreach (range(0, $x) as $i) { | |
yield $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
use std::io; | |
use std::rand; | |
use std::cmp::Ordering; | |
fn main() { | |
println!("Guess the number!"); | |
let secret_number: u32 = (rand::random::<u32>() % 100) + 1; | |
loop { |
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
import http.server as httpserver | |
import functools | |
class Handler(httpserver.BaseHTTPRequestHandler): | |
_id = 'default' | |
_secret = 'default' | |
def __init__(self, request, client_addy, server, app_id, app_secret): | |
# super().__init__(...) kicks of request handler so set up | |
# before calling it |
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
final class CountableMemorySpool extends \Swift_MemorySpool implements \Countable | |
{ | |
public function count() | |
{ | |
return count($this->messages); | |
} | |
public function getMessages() | |
{ | |
return $this->messages; |
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 PMG\ExampleCustomer; | |
/** | |
* An API class for fetching custom metadata for a given customer post type. | |
*/ | |
final class CustomerMeta | |
{ | |
const WEBSITE_LINK = '_pmg_examplecustomer_websitelink'; |
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 | |
/* | |
Ideally this would be part of the language: | |
with (createAnObject() as $object) { | |
$object->doStuff(); | |
} | |
This is just sugar for: |
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 | |
interface Spam extends \Traversable | |
{ | |
// ... | |
} | |
final class Ham implements Spam, \IteratorAggregate | |
{ | |
public function getIterator() |