Git Product home page Git Product logo

everycolor's Introduction

everycolor

colors, all of 'em.

follow @everycolorbot on twitter if you wanna keep up on all the latest happenings in the world of color.

deployment guide

  1. get ruby, rake, and bundler

  2. run bundle install to get all those gems

  3. set up a scheduled task to run rake tweet

the magic bits

here is an exhaustive list of halfway-interesting problems I solved over the course of writing this thing:

  • randomly selecting colors without repeats: bog-standard PRNGs aren't guaranteed (as far as I'm aware) to generate n-bit numbers with a period of 2n, which is a necessity for something that claims to generate "every color." either I could store a list of colors generated since the inception of @everycolorbot and reroll if I get a repeat (which is hard; see below), or use a custom PRNG that does have a guaranteed period of 2n.

    solution: everycolor uses a 24-bit LFSR to generate numbers, using a set of taps (documented in everycolor.rb) which are guaranteed to have a period of 224 (which you can experimentally verify using the test_lfsr method.) I could've used a better PRNG, but it wasn't worth researching.

  • statelessness: heroku doesn't come stock with any stores of persistent data; the ephemeral file system associated with your dyno is destroyed when the dyno stops running. this makes it hard to store a history of every color that's been generated (see above). for the OAuth credentials required for @everycolorbot, standard config vars suffice, but there doesn't seem to be a way of updating config vars from inside a dyno, and in any case the docs say that your dyno gets restarted whenever a config var changes (which seems like it would lead to an infinite loop of tweets, Twitter jail, dogs and cats living together, mass hysteria, &c.)

    solution: everycolor uses Twitter itself as a store of persistent data, by reloading the last color it tweeted every time it goes to tweet.

everycolor's People

Contributors

vogon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

everycolor's Issues

does not generate #ffffff

as pointed out in an e-mail to me from Joshua Horowitz, a 24-bit LFSR actually has a period of 16,777,215, not 16,777,216 -- in particular, the all-bits-one state is a steady state and cannot be reached from other states, nor can it reach other states.

I need to go download the @everycolorbot twitter archive, look at the first color, and add special-case code to generate #ffffff immediately before either looping to it or terminating.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.