Skip to content

Instantly share code, notes, and snippets.

@zacwest
zacwest / baseball_standings.js
Last active Jun 13, 2022
Post Baseball standings to Slack. This code is awful, I don't know JavaScript, but it works. You probably need to figure out the emoticons for each team in your Slack.
View baseball_standings.js
var token = 'your-token-here'; // from https://erikberg.com/api for wildcard
var agent = 'Your/1.0 <user@agent>';
var fetch = require('node-fetch');
var hooks = {'https://hooks.slack.com/services/…': '#channel',
'https://hooks.slack.com/services/…': '#channel'};
var team_table = {
"los-angeles-dodgers": ":dodgerslogo:",
"san-francisco-giants": ":giants:",
View Silly dice roller
import Foundation
struct Dice : SequenceType {
typealias Generator = GeneratorOf<Int>
let dice:[Int]
init (rolls:Int, sides:Int) {
dice = Array(count:rolls, repeatedValue:sides)
}
func roll() -> Int {
return dice.map { Int(arc4random_uniform(UInt32($0 - 1)) + 1) }