Skip to content

Instantly share code, notes, and snippets.

@colinjfw
colinjfw / init.lua
Created September 6, 2025 20:10
nvim init.lua
-- bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
// Place your key bindings in this file to override the defaults
[
// New file uses cmd+n and a new folder uses cmd+shift+n (or ctrl).
{
"key": "cmd+n",
"command": "explorer.newFile",
"when": "explorerViewletFocus"
},
{
"key": "cmd+enter",
+---------+ +--------+ +-----------+ +-------------+
| Tooling | | GitHub | | 3rd Party | | Your Server |
+---------+ +--------+ +-----------+ +-------------+
| | | |
| Create Deployment | | |
|--------------------->| | |
| | | |
| Deployment Created | | |
|<---------------------| | |
| | | |
def move(state)
head = state[:you][:body][0]
neck = state[:you][:body][1]
moves = ['up', 'down', 'left', 'right']
moves.each do |move|
coord = move_as_coord(move, head)
if !off_board(state, coord) && !coord_equal(coord, neck)
return { move: move }
end
def coord_equal(a, b)
a[:x] === b[:x] && a[:y] === b[:y]
end
def move(state)
head = state[:you][:body][0]
moves = ['up', 'down', 'left', 'right']
moves.each do |move|
coord = move_as_coord(move, head)
unless off_board(state, coord)
return { move: move }
end
end
def off_board(state, coord)
return true if coord[:x] < 0
return true if coord[:y] < 0
return true if coord[:y] >= state[:board][:height]
return true if coord[:x] >= state[:board][:height]
return false # If it makes it here we are ok.
end
@colinjfw
colinjfw / move_1.rb
Last active September 28, 2019 01:08
def move(state)
head = state[:you][:body][0]
moves = ['up', 'down', 'left', 'right']
moves.each do |move|
coord = move_as_coord(move, head)
# We now know where this is going to be!
end
end
def move_as_coord(move, head)
case move
when 'up'
return {x: head[:x], y: head[:y]-1}
when 'down'
return {x: head[:x], y: head[:y]+1}
when 'left'
return {x: head[:x]-1, y: head[:y]}
when 'right'
return {x: head[:x]+1, y: head[:y]}
def move(state)
head = state[:you][:body][0]
...
end