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 '[clojure.string :as string]) | |
(defn- make-rows [height] | |
(loop [out [] h height] | |
(if (< h 1) | |
(map #(apply str %) out) | |
(recur | |
(conj out (concat (repeat (- height h) \space) (repeat h \#))) | |
(dec h))))) |
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 perceptron [inputs weights bias] | |
{:pre [(= (count inputs) (count weights))]} | |
(let [combined (map * inputs weights)] | |
(if (< (+ (apply + combined) bias) 1) 0 1))) | |
(defn nand [one two] | |
(perceptron [one two] [-2 -2] 3)) | |
(defn adder [x y] | |
"Returns a vector of [carry-bit sum-bit]" |
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 foo(bool $hello=true) | |
{ | |
// ... | |
} |
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 foo(boolean $hello=true) | |
{ | |
// ... | |
} | |
/* | |
local> php -l example.php | |
PHP Fatal error: Default value for parameters with a class type hint can only be NULL in t.php on line 3 |
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 | |
/** | |
* Copyright (c) 2016 PMG <https://www.pmg.com> | |
* | |
* License: MIT | |
*/ | |
use Symfony\Component\PropertyAccess\PropertyAccess; | |
use Symfony\Component\PropertyAccess\PropertyAccessorInterface; | |
use Symfony\Component\Form\FormEvents; |
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 | |
$query = new \WP_Query(array( | |
// ... | |
)); | |
foreach ($query->chunk(4) as $chunk): ?> | |
<div class="row"> | |
<?php while ($chunk->have_posts()): $chunk->the_post(); ?> |
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 | |
/** | |
* Copyright (c) 2016 PMG <https://www.pmg.com> | |
* | |
* License: MIT | |
*/ | |
use Symfony\Component\PropertyAccess\PropertyAccess; | |
use Symfony\Component\PropertyAccess\PropertyAccessorInterface; | |
use Symfony\Component\Form\FormEvents; |
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
find path/to/Bundle/Controller -type f -name '*.php' -exec sed -i '' 's/createForm(new \(.*\)()/createForm(\1::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
var assign = require('object-assign'); | |
var Promise = require('es6-promise').Promise; | |
var EventEmitter = require('eventemitter2').EventEmitter2; | |
function buildQueryString(object, prefix) { | |
var out = []; | |
for (var prop in object) { | |
if (!object.hasOwnProperty(prop)) { | |
continue; | |
} |
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 boot | |
(require '[clojure.string :as string]) | |
(defn- str->int [s] | |
(Integer/parseInt s)) | |
(defn- positive? [n] | |
(> n 0)) |