Skip to content

Instantly share code, notes, and snippets.

View gist:7a293c6a7c4bd27cef7dcfe3538b7367
const std = @import("std");
const warn = std.debug.warn;
const fmt = std.fmt;
const mem = std.mem;
var alloc = &std.heap.DirectAllocator.init().allocator;
pub const Expr = union(enum) {
Literal: Literal,
};
View gist:04e2e921cb54474fcee0a6f20a1e3d98
const std = @import("std");
const warn = std.debug.warn;
const fmt = std.fmt;
const mem = std.mem;
var alloc = &std.heap.DirectAllocator.init().allocator;
pub const ExprType = enum {
Binary,
Literal,
View gist:8e1d2289cfbb3c842d61ebdddf0316f7
const std = @import("std");
const Food = enum {
Pretzel,
Cheese,
Cucumber,
};
pub fn main() !void {
const alloc = &std.heap.DirectAllocator.init().allocator;
View gist:8e98cf20714947c817c1e37dac58061b
### Keybase proof
I hereby claim:
* I am cgag on github.
* I am cgag (https://keybase.io/cgag) on keybase.
* I have a public key ASCdMKp9h-XuWWOZPnlJZar9aXF32-6PMDR26pd-3H86Ygo
To claim this, I am signing this object:
@cgag
cgag / test.zig
Last active Sep 10, 2017
ir.cpp err
View test.zig
The initial program I tried to run:
```
pub fn main() -> %void {
var m2 = &2;
%%io.stdout.printf("hello: {}\n", m2);
}
```
error:
View richhickey.md

Rich Hickey on becoming a better developer

Rich Hickey • 3 years ago

Sorry, I have to disagree with the entire premise here.

A wide variety of experiences might lead to well-roundedness, but not to greatness, nor even goodness. By constantly switching from one thing to another you are always reaching above your comfort zone, yes, but doing so by resetting your skill and knowledge level to zero.

Mastery comes from a combination of at least several of the following:

@cgag
cgag / log.go
Created May 22, 2016 — forked from cespare/log.go
Golang apache logging
View log.go
type ApacheLogRecord struct {
http.ResponseWriter
ip string
time time.Time
method, uri, protocol string
status int
responseBytes int64
elapsedTime time.Duration
}
@cgag
cgag / gist:d0c712d84960458f7501
Created Sep 7, 2015
attemping to build neovim on void linux. Fixed by symlinking /bin/sh to bash
View gist:d0c712d84960458f7501
inja -C .deps
ninja: Entering directory `.deps'
[1/25] Performing build step for 'unibilium'
[2/25] No patch step for 'luarocks'
[3/25] Performing install step for 'libvterm'
[4/25] No update step for 'luarocks'
[5/25] Performing configure step for 'luarocks'
FAILED: cd /home/cgag/tmp/neovim/.deps/build/src/unibilium && /usr/bin/make CC=/usr/bin/cc PREFIX=/home/cgag/tmp/neovim/.deps/usr CFLAGS=-fPIC && /usr/bin/cmake -E touch /home/cgag/tmp/neovim/.deps/build/src/unibilium-stamp/unibilium-build
make[1]: Entering directory '/home/cgag/tmp/neovim/.deps/build/src/unibilium'
libtool --mode=compile --tag=CC /usr/bin/cc -I. -Wall -std=c99 -fPIC -o unibilium.lo -c unibilium.c
View gist:1387e2f83abc578073e3

Things that programmers don't know but should

(A book that I might eventually write!)

Gary Bernhardt

I imagine each of these chapters being about 2,000 words, making the whole book about the size of a small novel. For comparison, articles in large papers like the New York Times average about 1,200 words. Each topic gets whatever level of detail I can fit into that space. For simple topics, that's a lot of space: I can probably walk through a very basic, but working, implementation of the IP protocol.

View TrueColor.md

Colors in terminal

It's a common confusion about terminal colors... Actually we have this:

  • plain ascii
  • ansi escape codes (16 color codes with bold/italic and background)
  • 256 color palette (216 colors+16gray + ansi) (colors are 24bit)
  • 24bit true color (888 colors (aka 16 milion))
    printf "\x1b[${bg};2;${red};${green};${blue}m\n"