Inspired by Haskell, I wanted to see if I could replicate, using ES6 features, the repeat
function:
repeat :: a -> [a]
So as you can see in repeat.js
, I have done exactly that. However there are some caveats.
<?php | |
class RESTRequest | |
{ | |
public $response; | |
public $code; | |
private $handle; | |
private $session; | |
private $curlopts; |
# Remove stale modules directories, fast! | |
# | |
# Paste or source this file in your shell rc file (should work with Bash and ZSH) | |
# | |
# Optionally provide a path as first arg, and optionally a duration in days as second arg (default=30) | |
# e.g. clean_modules ~/github 60 | |
# Remove the "-exec du" line for faster operation (i.e. do not print sizes, which can be slow) | |
PROJECT_DIR=~/Projects | |
# If `bfs` is installed, use that for faster searching |
function asyncQuicksort(xs = []) { | |
// get the "head" and "tail" of the array | |
let [h, ...t] = xs | |
// create the initial Promise | |
return new Promise((res, rej) => { | |
// resolve immediately if "head" was undefined | |
if (!h) return res([]) | |
// recurse for the "left" half of the partition | |
asyncQuicksort(t.filter(a => a <= h)).then(a => { | |
// recurse for the "right" half of the partition |
Inspired by Haskell, I wanted to see if I could replicate, using ES6 features, the repeat
function:
repeat :: a -> [a]
So as you can see in repeat.js
, I have done exactly that. However there are some caveats.
{ | |
"cmd": ["/usr/local/bin/babel-node $file"], | |
"shell": true, | |
"selector": "*.js" | |
} |
import { sudokuVerifier } from '../src/sudoku_verifier' | |
import problems, { sudoku } from '../problems' | |
function assertValid(problem, solution) { | |
expect( | |
sudokuVerifier({ problem, solution }) | |
).toEqual({ status: 'valid', invalidIndexes: [ ] }) | |
} | |
function assertIncomplete(problem, solution) { |
<?php | |
// Stupidly simple PHP proxy for AJAX (HTTP GET) requests. Written by Kevin Lanni. | |
$dest = ''; // Set to the remote script URL (i.e. http://remotehost.com/some.php) | |
$a = array(); | |
foreach ($_GET as $k=>$v) { | |
$a[] = "{$k}={$v}"; | |
} |
I hereby claim:
To claim this, I am signing this object:
Automate your developer workflow with git-guppy. git-guppy allows you to add git-hooks to your project repository that are automatically installed when users clone and install your repository, so you won't have to worry about developers skipping essential workflow steps and bypassing your project guidelines.
So let's use a unit test scenario to illustrate an example. We're going to run unit tests before every commit (pre-commit hook) and reject the commit if the tests fail (giving the developer a chance to fix their tests before committing broken code).
<?php | |
/* JSONP_Example.php | |
* Author: Kevin Lanni | |
* Description: Demonstrates how to create a simple public Web API using JSONP responses | |
* This is useful for opening Web APIs for public use without the need for proxying or other SOP work-arounds. | |
* This example does not demonstrate API keys or any other method of authentication. | |
*/ | |
// Supply a header to set the proper expectation for the client browser | |
header('Content-Type: application/json'); |