Git Product home page Git Product logo

rc-place's Introduction

rc-place

Go Report Card License: AGPL v3 Coverage: O

A place for Recursers to color pixels, inspired by r/place. For architecture details, see How We Built r/Place .

RC Place Image from 2022-03-21

Build and Run

Create an OAuth application at https://www.recurse.com/settings/apps with proper redirect URI (http://localhost:8080/auth for local run). Make sure to set your app's ID, Secret, and Redirect URI in your environmental variables (see .env.example). You can optionally set your own redis host and password.

# Load your environmental variables after setting them
๐ŸŽจ source .env.example

# Run Redis via docker container
๐ŸŽจ docker run --name rc-place-redis -d -p 6379:6379 redis

# Run rc-place app
๐ŸŽจ make run

๐ŸŽ‰ rc-place should now be running at http://localhost:8080

Other tools

# Use Redis docker
๐ŸŽจ docker exec -it rc-place-redis redis-cli

# Reset board
๐ŸŽจ del $REDIS_BOARD_KEY 

# Get board at offset (x + boardSize*y)
๐ŸŽจ bitfield $REDIS_BOARD_KEY GET u4 #$OFFSET

Deploy

๐ŸŽจ fly deploy

Rest API

Update Tile


Update the color of a tile located at column x, row y.

  • URL: /tile
  • Method: POST
  • Data Params:

Request Body

{
    "x": 2,
    "y": 4,
    "color": "red"
}

Valid colors: black, forest, green, lime, blue, cornflowerblue, sky, cyan, red, burnt-orange, orange, yellow, purple, hot-pink, pink, white.

  • Success Response: 200

  • Error Response

    • Code 400 Bad Request
      • Invalid json body: make sure you're using the right types, valid colors, and your body is encoded correctly.
    • Code 401 Unauthorized
      • Make sure you have a valid personal access token in your authorization header.
    • Code 425 Too Early
      • There's a time limit for sending requests, make sure to wait one second between requests.
    • Code 500 Internal Server Error
  • Sample Call

๐ŸŽจ curl -X POST http://localhost:8080/tile -H "Content-Type: application/json" -d '{"x": 3, "y": 3, "color": "red"}' -H "Authorization: Bearer $PERSONAL_ACCESS_TOKEN"

Get tiles


Get all tiles.

  • URL: /tiles
  • Method: GET
  • Data Params:

Query Parameters

  • format (OPTIONAL, default "string"): {"int", "string"}
  • Success Response: 200
{
  "tiles" : [[1, 2], [3, 4]],
  "height": 2,
  "width": 2,
  "updateLimitInMs": 10
}
  • Error Response

    • Code 401 Unauthorized
      • Make sure you have a valid personal access token in your authorization header.
    • Code 500 Internal Server Error
      • You may have found a bug! You're encourage to file an issue with the steps to reproduce.
  • Sample Call

๐ŸŽจ curl http://localhost:8080/tiles -H "Authorization: Bearer $PERSONAL_ACCESS_TOKEN"

Get tile


Get a tile.

  • URL: /tile
  • Method: GET
  • Data Params:

Query Parameters

  • x (REQUIRED): column, 0 <= x < BOARD_SIZE
  • y (REQUIRED): row, 0 <= y < BOARD_SIZE
  • Success Response: 200
{
  "color" : "red",
  "x": 2,
  "y": 2,
  "lastUpdated":"2022-03-29T00:56:58.632329-04:00",
  "lastEditor":"3731-joseph-tobin"
}
  • Error Response

    • Code 400 Bad Request
      • Invalid query parms: make sure you're using the valid query parameters within boundaries.
    • Code 401 Unauthorized
      • Make sure you have a valid personal access token in your authorization header.
    • Code 500 Internal Server Error
      • You may have found a bug! You're encourage to file an issue with the steps to reproduce.
  • Sample Call

๐ŸŽจ curl http://localhost:8080/tile?x=15&y=3 -H "Authorization: Bearer $PERSONAL_ACCESS_TOKEN"

rc-place's People

Contributors

connorguy avatar dangrous avatar jeffawang avatar jobin212 avatar mcastorina avatar ysono avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rc-place's Issues

Get board state API

  • API to get the entire board state
  • API to get a single pixel state

We should be able to get the board state via both the websocket and the authenticated API.

Create image2pixel map

I'd like an easy way to convert my favorite picture into a map that my bot can read to draw the image on rc-place

TODO before launch

  • Big, draggable board
  • Timelapse (See https://community.fly.io/t/how-to-copy-files-off-a-vm/1651/6)
  • Ensure thread safety (mutex)
  • Bot creation session, examples (multiple languages)
  • GET /tile -- get color, last updated, last updater of single tile (nice to have)
  • BONUS MSPaint features
  • BONUS Give web client a message/timer/API until they can place again -- e.g. you have 0.4 s until you can update

Stats board

  • Stats by color
  • Stats by user ("high score")

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.