A game designed to let you show off your code-fu by solving problems in the least number of characters.
|
1 day ago | |
---|---|---|
.github | 2 days ago | |
cmd | 5 months ago | |
config | 1 day ago | |
css | 5 days ago | |
db | 3 months ago | |
discord | 1 day ago | |
docker | 2 days ago | |
fonts | 1 month ago | |
github | 3 months ago | |
golfer | 5 months ago | |
hole | 1 day ago | |
js | 1 day ago | |
langs | 1 day ago | |
middleware | 8 months ago | |
null | 1 year ago | |
oauth | 5 months ago | |
ordered | 3 years ago | |
pager | 11 months ago | |
pretty | 4 months ago | |
public | 6 months ago | |
routes | 1 day ago | |
session | 2 years ago | |
sql | 5 days ago | |
svg | 5 days ago | |
t | 2 days ago | |
utils | 3 months ago | |
views | 5 days ago | |
xt | 3 years ago | |
zone | 6 months ago | |
.dockerignore | 7 months ago | |
.gitignore | 7 months ago | |
.golangci.toml | 4 months ago | |
CONTRIBUTING.md | 2 months ago | |
LICENSE | 7 years ago | |
META6.json | 4 years ago | |
Makefile | 1 week ago | |
README.md | 9 months ago | |
Vagrantfile | 3 years ago | |
build-langs | 5 days ago | |
esbuild | 6 months ago | |
eslint.config.js | 1 year ago | |
go.mod | 1 week ago | |
go.sum | 1 week ago | |
latest-langs | 5 days ago | |
main.go | 1 month ago | |
package-lock.json | 3 days ago | |
package.json | 2 months ago | |
run-lang.c | 2 days ago | |
svgo.config.js | 4 months ago | |
tsconfig.json | 3 years ago |
This is the repository behind the website and community https://code.golf
Alternatively, see the Vagrant section below to create a virtual machine with everything pre-installed.
Install the local CA: ``` $ make cert Using the local CA at "~/.local/share/mkcert" ✨ The local CA is now installed in the system trust store! ⚡️ The local CA is now installed in the Firefox and/or Chrome/Chromium trust store (requires browser restart)! 🦊
Created a new certificate valid for the following names 📜
The certificate is at "./localhost.pem" and the key at "./localhost-key.pem" ✅
3. Install the NPM packages:
> *NOTE*: if your host OS is not the same architecture / executable format as
> your Docker environment, this can result in incorrect format binaries installed
> into `node_modules`, so you may want to skip this step.
$ npm install
4. Bring up the website:
$ make dev
5. Optionally, load information from the code.golf database.
$ go run utils/update_sql_from_api.go
6. Navigate to https://localhost
## Hacking
Some of ancillary scripts are written in Raku, to run these ensure you have a
recent install of Raku installed and use Zef to install the dependencies:
$ zef install --deps-only .
## TypeScript
The `js/` directory contains the TypeScript files which will be transpiled by
`esbuild` into JavaScript files for serving. `.tsx` files can additionally
make use of [JSX](https://www.typescriptlang.org/docs/handbook/jsx.html).
## Linting
Run `make lint` to lint the code before a pull request. This lints the TypeScript code, then the Go code.
In Visual Studio Code, the following settings are helpful for editor support for ESLint:
"eslint.validate": ["typescript", "typescriptreact"], "eslint.format.enable": true, "editor.defaultFormatter": "dbaeumer.vscode-eslint"
## Testing
1. Run the unit tests:
$ make test
2. Run the e2e tests:
> *NOTE*: Any changes to the languages need to be re-built with `build-langs` before e2e will pick up the changes.
$ make e2e
## Vagrant
Using Vagrant and VirtualBox, with one command you can create a virtual machine, install all of the other dependencies onto it (Docker, Docker Compose, Go, Raku + zef dependencies, npm, etc.), and forward port 443 (https) to it.
1. Install the dependencies:
* [Vagrant](https://www.vagrantup.com/downloads)
* [VirtualBox](https://www.virtualbox.org/)
If you have homebrew, you can install with:
$ brew install vagrant virtualbox
2. Create the virtual machine:
$ git config core.autocrlf false && git checkout utils/vagrant-bootstrap && vagrant up
3. Install certificates. Ideally, you should run the following command outside of the virtual machine, the same as in the quickstart, because it will install the certificate in your browser. Alternatively, you can run the command in a virtual machine shell and then install the certificates manually.
$ make cert
or
$ vagrant ssh --command 'cd /vagrant/ && make cert'
4. Bring up the website:
$ vagrant ssh --command 'cd /vagrant/ && make dev'
5. Optionally, load information from the code.golf database.
$ vagrant ssh --command 'cd /vagrant/ && go run utils/update_sql_from_api.go'
6. Navigate to https://localhost
## Database Access
If you have [PostgreSQL](https://www.postgresql.org/download/) installed You can access the SQL database directly with the following command. If you are using Vagrant, PostgreSQL is pre-installed.
$ make db-dev
## API
Validate API definition with [vacuum](https://api.quobix.com/report?url=https://code.golf/api).
## Style
URL slugs are consistently abbreviated (e.g. cheevos, langs, stats) but page
titles aren't (e.g. Achievements, Languages, Statistics).
Paginated URLs use a trailing number but only on pages after the first (e.g.
/rankings/medals/all, /rankings/medals/all/2, etc.).
## arm64/aarch64 Architecture (Ex: Apple Silicon)
If your machine has arm64 architecture, then there are a few options for running a local instance of the site.
You can attempt to use QEMU emulation which is supported by Docker Desktop, but may be slower.
The default when you `make dev` is that the docker images will be built with arm64 architecture.
You may be able to use some languages without building them locally.
Here is a list of some of the languages that are able to run the sample code, without rebuilding individual docker containers:
* AWK
* Bash
* Berry
* Lua
* Perl
* PHP
* Python
* Raku
* Ruby
* sed
* SQL
* Wren
For other languages, you will need to build them locally. For example:
$ ./build-langs --no-push C Go JavaScript
Otherwise, you may see the following error:
assertion failed [!result.is_error]: Unable to open /proc/sys/vm/mmap_min_addr (VMAllocationTracker.cpp:281 init) signal: trace/breakpoint trap ```