Skip to content

Instantly share code, notes, and snippets.

@dtipson
dtipson / cellular automata with quasi-comonads.js
Last active November 9, 2021 14:41
Using a comonad(ish) pattern to create cellular automata in a more functional way. Inspired by this episode of funfunfunction: https://www.youtube.com/watch?v=bc-fVdbjAwk
/*
Native Arrays are not great structures for cellular automata.
Non-empty, circular, doubly-linked lists would be ideal...
but all we really need to do is write a comonadic-like interface
such that it _pretends_ that the array is circular, and can thus
pass the exfn below a sort of "local" slice of an Array as if it were circular.
So you can mostly ignore the implementation mess below
*/
Array.prototype.extendNear = function(exfn){
const len = this.length;
@tuupola
tuupola / index.php
Last active March 4, 2019 09:47
Use JWT Authentication middleware with ZF Expressive
<?php
use Zend\Expressive\AppFactory;
use Firebase\JWT\JWT;
use Slim\Middleware\JwtAuthentication;
chdir(dirname(__DIR__));
require "vendor/autoload.php";
$app = AppFactory::create();
@schubert
schubert / capistrano_colors.rb
Created August 9, 2012 21:46
color hooks for capistrano deployments
namespace :deploy do
reset = "\033[0m"
success = "\033[32m" # Green
failure = "\033[31m" # Bright Red
task :completed do
puts "#{success}"
puts "*" * 40
puts "SUCCESS"
puts "*" * 40
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>SoundCloud OAuth 2 User Agent Authentication Flow Demo</title>
<script type="text/javascript" charset="utf-8" src="javascript/jquery-1.4.2.js"></script>
<script type="text/javascript" charset="utf-8">
$(function () {
var extractToken = function(hash) {