• Stars
    star
    678
  • Rank 66,609 (Top 2 %)
  • Language
    Ruby
  • License
    MIT License
  • Created almost 14 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Real Vim ninjas count every keystroke - do you?

VimGolf.com

Build Status Code Climate Issue Count

Real Vim ninjas count every keystroke - do you? Head on over to vimgolf.com, pick a challenge, and show us what you've got!

  • Each challenge provides an input file, and an output file
  • Your goal is to modify the input file such that it matches the output
  • Once you install the vimgolf CLI, pick a challenge, open a prompt and put away!

When you launch a challenge from the command line, it will be downloaded from the site and a local Vim session will be launched, which will log every keystroke you make. Once you're done, simply :wq (write and quit) the session and we will score your input and upload it back to the site!

Setup & Play

$> gem install vimgolf

(Go to vimgolf.com, sign in, and grab your API key)
$> vimgolf setup

(Pick a challenge on vimgolf.com)
$> vimgolf put [challenge ID]

Golfing without ruby installation: use docker

$> docker run --rm -it -e "key=YOUR_VIMGOLF_KEY" ghcr.io/filbranden/vimgolf challenge_ID

Playing from other editors

Emacs

There's a lightly maintained interface to play VimGolf challenges in Emacs over at vimgolf.el

VimGolf.com web app

# start local server
$> bundle exec unicorn -c config/unicorn.rb -E development

# deploy to Heroku
$> git push heroku master

Run tests

Go to the root folder and run bundle exec rake.

How to contribute

This part is for people not familliar with ruby ecosystem

Installation

You need:

  • ruby
  • gem bundler
  • sqlite3 (library version 3.25 or newer, on your local system); or
  • postgresql

ruby

You need a ruby version, same as .ruby-version

I recommend using rbenv, see https://github.com/rbenv/rbenv to install and manage ruby version.

cd $VIMGOLF_PATH
rbenv install

bundler

Bundler is a gem that aim to manage gem per project.

gem install bundler:1.17.2

Then you need all gems for the apps

bundle install

Using sqlite3 for development (and testing)

It is possible to get a fully functionnal app running locally using SQLite3 only. This is the default adapter for development and testing (it makes for easier ramp up, since you don't need to set up an instance of Postgres and create the appropriate users.)

Note that due to the use of SQL window functions, you need an SQLite3 library version 3.25 or newer installed on your system. The Ruby gem will use the locally installed library, so that is a pre-requisite to using SQLite3. The SQLite3 library shipped on Ubuntu 18.04 is too old, the one on Ubuntu 20.04 is new enough.

Using Postgres for development

You can also use a Postgres database for development (and testing.)

Install and start a Postgres instance running locally on your development host.

The app will run under your user, so create a Postgres user with the same name as your local user and give that user the ability to create databases. This is usually accomplished with the following command:

sudo -u postgres createuser -d $(whoami)

When running any of the Ruby and Rails code, in order to use the Postgres adapter in the development and test environments, export environment variable DATABASE_ADAPTER=pg.

The database names configured will be vimgolf_development and vimgolf_test for the respective environments.

Seed database

Read db/seeds.rb to understand parameters to define how many users, challenges and entries to create.

When creating a local development database on SQLite3 (the default adapter), use the following procedure:

# make the index page works - create collection "challenges"
bundle exec rails db:drop db:setup

# or add many challenges users and entries
bundle exec rails db:drop db:setup challenges=40 users=30 entries=20

When creating a local development database on Postgres, do not use the db:setup and db:reset targets, as those targets rely on loading the db/schema.rb file, but that file contains a schema dump compatible with the SQLite3 database and would possibly produce a broken setup under Postgres. Instead, use db:migrate and db:migrate:reset to create the database running through the Rails migrations as appropriate.

# under postgres
DATABASE_ADAPTER=pg bundle exec rails db:migrate:reset
DATABASE_ADAPTER=pg bundle exec rails db:seed challenges=40 users=30 entries=20

Run the app

Start the server:

bundle exec unicorn -c config/unicorn.rb -E development

(If using Postgres, make sure you're passing it DATABASE_ADAPTER=pg through the environment.)

Open your browser to localhost:8080.

You can check the Rails logs under:

tail -f log/development.log

Logged in user under Development

When click on 'Sign In with Twitter' under development, you will almost certainly get:

OAuth::Unauthorized
401 Authorization Required

As a workaround, you can edit file app/controllers/application_controller.rb and replace:

    @current_user ||= User.where(uid: session[:user]).first if session[:user]

With:

    @current_user ||= User.first

Or, if you have a particular user in mind:

    @current_user ||= User.find_by_nickname('myuser')

More Repositories

1

videospeed

HTML5 video speed controller (for Google Chrome)
JavaScript
3,812
star
2

ga-beacon

Google Analytics collector-as-a-service (using GA measurement protocol).
Go
3,536
star
3

gharchive.org

GH Archive is a project to record the public GitHub timeline, archive it, and make it easily accessible for further analysis.
Ruby
2,680
star
4

em-websocket

EventMachine based WebSocket server
Ruby
1,690
star
5

decisiontree

ID3-based implementation of the ML Decision Tree algorithm
Ruby
1,437
star
6

em-http-request

Asynchronous HTTP Client (EventMachine + Ruby)
Ruby
1,219
star
7

em-synchrony

Fiber aware EventMachine clients and convenience classes
Ruby
1,041
star
8

http-2

Pure Ruby implementation of HTTP/2 protocol
Ruby
894
star
9

bugspots

Implementation of simple bug prediction hotspot heuristic
Ruby
853
star
10

agent

Agent is an attempt at modelling Go-like concurrency, in Ruby
Ruby
729
star
11

em-proxy

EventMachine Proxy DSL for writing high-performance transparent / intercepting proxies in Ruby
Ruby
662
star
12

node-spdyproxy

SPDY forwarding proxy - fast and secure
JavaScript
527
star
13

bloomfilter-rb

BloomFilter(s) in Ruby: Native counting filter + Redis counting/non-counting filters
C
472
star
14

async-rails

async Rails 3 stack demo
Ruby
465
star
15

istlsfastyet.com

Is TLS fast yet? Yes, yes it is.
HTML
422
star
16

hackernews-button

Embeddable Hacker News button + vote counter for your site
Go
415
star
17

http-client-hints

Ruby
402
star
18

spdy

SPDY is a protocol designed to reduce latency of web pages
Ruby
315
star
19

hpbn.co

High Performance Browser Networking (O'Reilly)
HTML
299
star
20

webp-detect

WebP with Accept negotiation
C++
242
star
21

zeroconf-router

Zero-config reverse proxies: let's get there!
Ruby
206
star
22

autoperf

Ruby driver for httperf - automated load and performance testing
Ruby
179
star
23

PubSubHubbub

Asynchronous PubSubHubbub Ruby Client
Ruby
175
star
24

heroku-buildpack-dart

Heroku buildpack for Dart
Shell
170
star
25

rack-speedtracer

SpeedTracer middleware for server side debugging
Ruby
155
star
26

textquery

Evaluate any text against a collection of match rules
Ruby
145
star
27

tokyo-recipes

Lean & mean Tokyo Cabinet recipes (with Lua)
Lua
143
star
28

slowgrowl

Surface slow code paths in your Rails 3 app via Growl
Ruby
116
star
29

mneme

Mneme is an HTTP web-service for recording and identifying previously seen records - aka, duplicate detection.
Ruby
108
star
30

RRRDTool

Round robin database pattern via Redis sorted sets
Ruby
79
star
31

pregel

Single-node implementation of Google's Pregel framework for graph processing.
Ruby
74
star
32

gmetric

Pure Ruby interface for generating Ganglia gmetric packets
Ruby
69
star
33

rack-aggregate

Rack response-time statistics aggregator middleware
Ruby
67
star
34

em-jack

An Evented Beanstalk Client
Ruby
64
star
35

rb-pagerank

Code from RailsConf '09 pres: Building Mini Google in Ruby
Ruby
54
star
36

closure-sprockets

Sprockets processor for Google's Closure tools
Python
54
star
37

netinfo-monitor

Displays network quality as reported by Network Information API.
JavaScript
48
star
38

shopify-core-web-vitals

This embedded app provides a report on how real-world Google Chrome users experience the Shopify-powered storefront, as captured by the Chrome UX Report, and enables the site owner to benchmark their site against a custom list of competitors.
Ruby
48
star
39

libsnappy

Snappy, a fast compressor/decompressor (courtesy of Google)
Ruby
46
star
40

hydra5

Load-balanced (multi-headed) SOCKS5 proxy
Ruby
42
star
41

zdevice

ZDevice is a Ruby DSL for assembling ZeroMQ routing devices, with support for the ZDCF configuration syntax
Ruby
42
star
42

ruby2lolz

Ruby to Lolcode translator, kthnxbai.
Ruby
38
star
43

bmr-wordcount

Browser Map-Reduce: distributed word count example
Ruby
33
star
44

resource-hints

Moved to...
JavaScript
32
star
45

gitter

XML history generator for CodeSwarm
32
star
46

em-socksify

Transparent proxy support for any EventMachine protocol
Ruby
31
star
47

em-handlersocket

EventMachine HandlerSocket MySQL plugin for direct read/write of InnoDB tables
Ruby
29
star
48

canicrawl

Hosted robots.txt permissions verifier
Go
23
star
49

udacity-webperf

JavaScript
17
star
50

omnipipe

web pipes for your browser's omnibar!
Ruby
12
star
51

issue-tracker

W3C webperf issue tracker
JavaScript
11
star
52

contextual

runtime contextual HTML autoescaper
Ruby
10
star
53

presentations

Slides, notes, code examples from some of the bigger conferences & talks.
9
star
54

libgeohash

Ruby FFI wrapper for libgeohash
Ruby
7
star
55

performance-observer

JavaScript
7
star
56

ImageQuote

Convert text quotes to images
Ruby
7
star
57

resourcehints.info

HTML
2
star
58

igrigorik

1
star