A game designed to let you show off your code-fu by solving problems in the least number of characters.

James Raspass 76f76b3272 Update feeds 1 day ago
.github bf6a514867 Stop commenting on dirty PRs 2 days ago
cmd 69117b7504 Calculate digest of each lang 5 months ago
config 3c72c36b75 Make "Topological Sort" live 1 day ago
css 378c2dbd12 Search nav (#2010) 5 days ago
db 87f84aede9 Simplify db.Queryable slightly 3 months ago
discord 3c72c36b75 Make "Topological Sort" live 1 day ago
docker 4684500226 Move the website to Go 1.25rc2 2 days ago
fonts de408b86ca Add "Overflowing" and "Into Space!" cheevos 1 month ago
github 3938f4a34f Add /wiki/tutorial 3 months ago
golfer 44afb3ff18 Replace NullCountry with *Country 5 months ago
hole d8ae8a93d5 Add two test cases star-wars-gpt.go (#2322) 1 day ago
js 6e44719819 Improve search nav (#2355) 1 day ago
langs a1721938d3 Bump JavaScript (#2359) 1 day ago
middleware 6ca6a7d876 Simplify & speedup middleware.RedirHolesLangs 8 months ago
null 6898279084 Add null.NullIfZero 1 year ago
oauth 3f348e62e7 Use golang.org/x/oauth2/endpoints package 5 months ago
ordered f5f332f0f8 s/interface{}/any/g 3 years ago
pager 3ed79d052f Bump per page from 60 to 75 11 months ago
pretty 768883818d Make better use of the new testing API 4 months ago
public 2589efdd52 Move logo-fill.svg to public/, it's unused 6 months ago
routes 76f76b3272 Update feeds 1 day ago
session 2e3ff2419c Redesign how we store things in context 2 years ago
sql 8bb114ec36 Add Umka language (#1985) 5 days ago
svg 8bb114ec36 Add Umka language (#1985) 5 days ago
t 8c2ecad4bc Test examples with an alternative hole (#2356) 2 days ago
utils 775a94a4ee Fix another bug in utils/update_sql_from_api.go 3 months ago
views 378c2dbd12 Search nav (#2010) 5 days ago
xt e8bcba6d8a Ensure all hole links return 200 3 years ago
zone ab6995ad8d Try the upcoming Go version for the website 6 months ago
.dockerignore bea23112d6 Quicker deploys: don't always rebuild assets 7 months ago
.gitignore e95826d0d8 Narrow sql gitignore to *.gz (#1752) 7 months ago
.golangci.toml 0a32fd4d77 Bump & restore golangci-lint 4 months ago
CONTRIBUTING.md 2b856ab5f8 Custom judges (#1351) 2 months ago
LICENSE 6afc3ee57c Add a LICENSE file 7 years ago
META6.json 909a4ed03e TOML::Thumb is now published 4 years ago
Makefile 42a2a435ce Bump Go linter 1 week ago
README.md 1c250be698 Update `README.md` (#1496) 9 months ago
Vagrantfile 426978a4ef Add Vagrantfile for easy setup of a VM with all dependencies. (#544) 3 years ago
build-langs 8bb114ec36 Add Umka language (#1985) 5 days ago
esbuild 7102b03eab Serve lang logos externally 6 months ago
eslint.config.js ce112c8e99 Bump ESLint 1 year ago
go.mod 0a02b92df4 Bump deps 1 week ago
go.sum 0a02b92df4 Bump deps 1 week ago
latest-langs 8bb114ec36 Add Umka language (#1985) 5 days ago
main.go de408b86ca Add "Overflowing" and "Into Space!" cheevos 1 month ago
package-lock.json 588b0a94aa Bump deps 3 days ago
package.json 65c0d31a3f Unpin & bump ESLint 2 months ago
run-lang.c a5c943257a run-lang: add new syscalls 2 days ago
svgo.config.js cb55c0e135 Disable SVGO's `convertTransform` plugin (#2021) 4 months ago
tsconfig.json 74e202ad47 Finally switch to NG! 3 years ago

README.md

Code Golf

This is the repository behind the website and community https://code.golf

Quickstart

Alternatively, see the Vagrant section below to create a virtual machine with everything pre-installed.

  1. Install dependencies:
  2. Docker
  3. Docker Compose
  4. Go
  5. make - most likely already on your system
  6. mkcert
  7. npm

  8. 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 📜

  • "localhost"

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 ```