Skip to content

Instantly share code, notes, and snippets.

Basic Neovim Configuration from scratch

The directory structure

nvim/
  after/
  | ftplugin/
  |   lua.lua
 | rb.lua
program : statement_seq
statement_seq : statement {sep statement}
statement : var_decl
| class_decl
| method_decl
| "if" expression opt_then statement_seq ["else" statement_seq] "end"
| "while" expression opt_do statement_seq "end"
| "return" expression
// Compiler
//
static void endScope() {
current->scopeDepth--;
while (current->localCount > 0 &&
current->locals[current->localCount - 1].depth >
current->scopeDepth) {
if (current->locals[current->localCount - 1].isCaptured) {

Rails React GraphQL Typescript Apollo [^1] [^2] [^3] [^4] [^5]

Base installation

# Create a new rails project
$ rails new my_app -j esbuild -c tailwind
$ cd my_app

# Add Sorbet
$ bundle add sorbet-static-and-runtime

Commands

Insert

  • 'i': Insert text before cursor
  • 'I': Insert at beginning of line
  • 'a': Append text after cursor
  • 'A': Append thext at end of line
  • 'o': Add new line after current
  • 'O': Add new line before current
@andersonsp
andersonsp / ULID.scala
Created August 5, 2020 18:46
Simple Binary ULID implementation in Scala
package io.andersonsp.ulid
import scala.util.{Failure, Success, Try}
import java.security.SecureRandom
// The components are encoded as 16 octets. Each component is encoded with the Most Significant Byte first (network byte order).
// 0 1 2 3
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | 32_bit_uint_time_high |
// Uncompressed version of
// https://gist.github.com/munificent/b1bcd969063da3e6c298be070a22b604
#include <time.h> // Robert Nystrom
#include <stdio.h> // @munificentbob
#include <stdlib.h> // for Ginny
#include <stdbool.h> // 2008-2019
const int HEIGHT = 40;
const int WIDTH = 80;
@andersonsp
andersonsp / mesh_c_io_export.py
Created October 21, 2019 13:13
Blender 2.8 OpenGL Buffer Exporter
# roxlu - 2019-08-04 - Blender 2.8
# ------------------------------------------------
# Very basic script that exports the vertices of the selected object
# to a .h and .cpp that you can use into your graphics app directly.
# Vertices are rotated to Y-up, -Z forward, following common OpenGL.
#
#
# Version:
# ------------------------------------------------
# v0.0.0 - 2019-08-04: First release
@andersonsp
andersonsp / zepl.c
Last active September 5, 2019 16:48
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
enum {
CW_LIT, CW_COMPILE, CW_CALL, CW_JMP,
CW_DEF, CW_IMM, CW__TOK, CW__EXEC, CW_EXIT, CW_ECHO,
CW_LAST
};