Giter Club home page Giter Club logo

isseptafcked's Introduction

What is this?

This is the code repository for the site www.isSeptaFcked.com. Or, if you are a regular commuter on SEPTA: www.isSeptaFucked.com.

Screenshot:

Why the profanity?

This, and many more questions are answered in the FAQ: http://www.isseptafucked.com/faq

How does it work?

Once every minute, it makes an API request for SEPTA's Regional Rail trains.
It then esitmates "fuckedness" as follows:

  • All trains < 10 minutes late: Not Fucked
  • 1 or more trains >= 10 minutes late and < 30 minutes late: A Little Fucked
  • 1 or more trains >= 30 minutes late: Fucked

If you have any questions, feel free to reach out to me. I can be reached here on GitHub or through the many social networks I am on: http://www.dmuth.org/contact

Media Coverage

Awards

Never thought I would win an award for profanity, Yet here we are. IsSeptaFucked won the "Best Side Prject" award in the NET/WORK Philly 2017 awards.

Architecture Overview

For fellow nerds out there, here's a brief rundown on how the various node.js modules are laid out:

  • views/ - Jade templates for public facing pages.
  • public/ - CSS and the site's robots.txt
  • node_modules/ - Modules installed with npm. One school of thought says I should just rely on the site's install.js file. But I always felt that a "git clone" operation should provide a complete working copy of the software. I may revise this decision when that directory gets sufficently large. ;-)
  • lib/logger.js - Handles custom logging in Express. Heroku uses proxies, and I would like to log the IP that incoming requests are forwarded for.
    • lib/septa/rr/api.js - Module that actually connects to SEPTA's Regional Rail API, and translates their data into something we can actually use.
    • lib/septa/rr/main.js - The main function in here is called at Express boot time, and it is responsible for calling SEPTA's API once a minute. It is also responsible for determing the level of "fuckedness" of Regional Rail.
    • lib/septa/rr/text.js - Create messages based on the lateness data.
    • lib/septa/bus/api.js - Module that actually connects to SEPTA's bus API, and translates their data into something we can actually use.
    • lib/septa/bus/main.js - The main function in here is called at Express boot time, and it is responsible for calling SEPTA's bus API once every 5 minutes. It is also responsible for determing the level of "fuckedness" of Regional Rail.
    • lib/septa/bus/text.js - Create messages based on the lateness data.
  • lib/sfw.js - Makes the determination if we are running under the SFW domain, and does filtering of strings.
  • routes/ - Each file in here corresponds to the same named URI, and handles requests to that URI.

Development

In Docker Compose

In Docker

  • docker build -t septa . && docker run -e TZ=EST5EDT -p 5000:5000 -it -v $(pwd):/mnt septa
  • http://localhost:5000/

In bash in Docker

  • docker build -t septa . && docker run -e TZ=EST5EDT -p 5000:5000 -it -v $(pwd):/mnt septa bash
    • You now have a shell in the Docker container. You can run npm start or any other command there.
  • Run npm start to spin up the webserver on port 5000.
  • http://localhost:5000/

The Manual Way (Y Tho)

Testing

At some point I'd like to have unit testing, but because the functionality of the website is relatively limited, at the current time it's quicker to uncomment sections of the code that have the string // Debug in order to change behavior of the site for texting purposes. Debug code can be found in these files:

  • lib/septa/rr/main.js
  • lib/septa/rr/api.js
  • lib/septa/rr/text.js
  • lib/septa/bus/main.js
  • lib/septa/bus/api.js
  • lib/septa/bus/text.js

Deployment in Fly.io

  • flyctl deploy - Deploy the app
  • flyctl status - Check the status of the app
  • flyctl open - Open the website in the browser
  • flyctl ips list - List IPs

Additional troubleshhoting can be found at https://fly.io/docs/getting-started/troubleshooting/.

Deployment in Heroku

  • brew tap heroku/brew && brew install heroku
    • Install the Heroku CLI
  • heroku login
    • Log in to Heroku
  • heroku git:remote -a isseptafcked
    • Add the remote for Heroku's Git repo as heroku
  • git remote -v
    • Verify that a remote called heroku exists
  • git push heroku
    • Push the changes out to Heroku

TODO

  • Express 4
  • Proper testing

isseptafcked's People

Contributors

dependabot[bot] avatar dmuth avatar tjwds 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

Watchers

 avatar  avatar  avatar  avatar  avatar

isseptafcked's Issues

Splunk Heroku logs

The heroku CLI app has a nice logs command.

I should consider running heroku logs --tail or similar and dump the logs into a file which I can then feed into Splunk Lab to analyze and look for anything interesting.

Include line suspensions & general alerts in RR status

In general, the status for RR depends on cumulative lateness of trains, and the status for city transit/buses depends on line cancellations. There are sometimes edge cases for the SEPTA system where an RR line is entirely suspended, but therefore has no late trains and does not count towards the level of fucked-ness. I'd like to propose somehow factoring that into the RR status, possibly from the other SEPTA alert API. This could also go the other way, factoring in cumulative lateness of buses on a route towards the bus network status, but I'm less sure of how to go about doing that. Could perhaps be done w/ the Transitview API but seems a bit harder to determine if any given route is meaningfully delayed, since we effectively get perfect service if (for example) all buses on a route with a 15 minute headway are exactly 15 minutes late.

I think the first part of my suggestion (factoring in some modifier to the fucked-ness if any RR lines are totally suspended) is pretty simple, and I plan to have a stab at it in a PR in the near future. Thanks!

Content Type

The API returns headers Content-Type: text/json, should return Content-Type: application/json.

CORS Error when trying to access the API

Hey!

I'm trying to build an Ionic application that consumes your API, and I keep running into CORS problems when making a GET request to get some data.

Would you mind enabling cross-origin requests on whatever server hosts your API?

Thanks!

Set up Slack for Alerting

  • Set up a Slack with channels for alerting status changes
  • There should be a separate "dev" channel for development
  • Slack hooks would be passed in via an environment variable
  • Put Slack info on the FAQ, with guidance for setting alerts on channels

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.