Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View bgoldman's full-sized avatar

Brandon Goldman bgoldman

  • FreshPay
  • San Francisco, CA
View GitHub Profile
@bgoldman
bgoldman / keybase.md
Last active March 17, 2019 20:17
keybase.md

Keybase proof

I hereby claim:

  • I am bgoldman on github.
  • I am bgoldman (https://keybase.io/bgoldman) on keybase.
  • I have a public key ASCKO89WtNZNNfV9MKyR2D8rjzjh_EdM3NNo3vhEN1yeqwo

To claim this, I am signing this object:

Proposal for Music Bot in Slack

Description

This describes a Slack bot that controls what would be played from a speaker in a physical room that corresponds to a Slack channel. Anybody that joins the Slack channel is a potential DJ. Each person lets the bot know the URL of their Spotify playlist, and the bot plays music from whoever the current DJ is. There are some commands to make things fun an interesting.

Commands

Verifying that +brandon is my Bitcoin username. You can send me #bitcoin here: https://onename.io/brandon
<?php
class Memoize {
private $_cache = array();
public $callback = null;
public static function transform($callback) {
return new Memoize($callback);
}
<?php
class Memoize {
private $_cache = array();
public $callback = null;
public static function transform($callback) {
return new Memoize($callback);
}
<?php
class Fib {
private static $_cache = array();
public static function calc($n) {
if ($n == 0 || $n == 1) {
return $n;
}
if (isset(self::$_cache[$n])) {
<?php
function fib($n) {
if ($n == 0 || $n == 1) {
return $n;
}
return fib($n - 1) + fib($n - 2);
}
echo 'Fibonacci numbers from 0-30.' . "\n";
var memoize = function(callback) {
var cache = {};
return function() {
var serializedArgs = JSON.stringify(arguments);
if (typeof cache[serializedArgs] != 'undefined') {
return cache[serializedArgs];
}
cache[serializedArgs] = callback.apply(this, arguments);
var memoize = function(callback) {
var cache = {};
return function() {
var serializedArgs = JSON.stringify(arguments);
if (typeof cache[serializedArgs] != 'undefined') {
return cache[serializedArgs];
}
cache[serializedArgs] = callback.apply(this, arguments);
var fib = function(n) {
if (n == 0 || n == 1) {
return n;
}
if (typeof fib._cache[n] != 'undefined') {
return fib._cache[n];
}
fib._cache[n] = fib(n - 1) + fib(n - 2);