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 MoneyFormatter | |
{ | |
public function format($value, $decimals=0, $decimalPoint='.', $thousandsSep=','); | |
} | |
class FormatterExtension extends \Twig_Extension | |
{ | |
private $formatter; |
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 | |
$one = array('two', 'one'); | |
list($two, $one) = $one; | |
var_dump($one, $two); | |
/* Output | |
string(3) "one" | |
string(1) "o" | |
*/ | |
/* |
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 -*- | |
""" | |
https://code.google.com/codejam/contest/32016/dashboard#s=p0 | |
The fuck is a "scalar product"? | |
http://en.wikipedia.org/wiki/Dot_product#Algebraic_definition | |
""" | |
import sys |
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 -*- | |
""" | |
https://code.google.com/codejam/contest/90101/dashboard#s=p0 | |
""" | |
import re | |
import sys |
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 | |
require __DIR__ . '/vendor/autoload.php'; | |
$s3 = Aws\S3\S3Client::factory($config); | |
$s3->registerStreamWrapper(); | |
$url = 's3://{$bucket}/{$key}'; | |
// Read CSV with fopen |
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
(defn read-line-crlf [instream] | |
(loop [sb (StringBuilder.) has-cr false] | |
(let [byt (.read instream)] | |
(when (= -1 byt) | |
(throw (java.io.IOException. "Unexpected end of input"))) | |
(let [chr (char byt)] | |
(if (and has-cr (= \newline chr)) | |
(.substring sb 0 (- (.length sb) 1)) | |
(recur | |
(.append sb chr) |
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 | |
class Foo | |
{ | |
private $name; | |
private static $defaultInstance = null; | |
/** | |
* Public constructor: create as many instance as you want | |
*/ |
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 -*- | |
""" | |
We have a little all-api python application that will have a client-side front | |
end and needed a script to run a dev server. This is it. | |
The app itself is a flask app, and will be mounted at `/api` in production. This | |
is an example of how to reproduce a setup like that with Werkzeug and Static. | |
:copyright: (c) 2014 PMG <http://pmg.co> |
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 -*- | |
""" | |
Sometimes you want all not found requests to go to a default file. A single page | |
JS app, for example, might use a client side router to show the appropriate view | |
from a single ``index.html``. | |
This is a simple example of accomplishing something like that with static: | |
https://github.com/lukearno/static |
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
function makeCurry(callable) { | |
return function () { | |
var args = []; | |
function inner() { | |
args = args.concat(Array.prototype.slice.call(arguments)); | |
if (args.length >= callable.length) { | |
return callable.apply(callable, args); | |
} | |
return inner; |
OlderNewer