Skip to content

Instantly share code, notes, and snippets.

@zacwest
zacwest / baseball_standings.js
Last active June 13, 2022 15:17
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.
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:",
anonymous
anonymous / Silly dice roller
Created September 24, 2014 06:52
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) }