Skip to content

Instantly share code, notes, and snippets.

@cgag
cgag / gist:7a293c6a7c4bd27cef7dcfe3538b7367
Last active September 9, 2018 23:59
zig compiler assertion
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,
};
@cgag
cgag / gist:04e2e921cb54474fcee0a6f20a1e3d98
Last active August 31, 2018 21:20
weird zig segfault
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,
const std = @import("std");
const Food = enum {
Pretzel,
Cheese,
Cucumber,
};
pub fn main() !void {
const alloc = &std.heap.DirectAllocator.init().allocator;
### 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 September 10, 2017 00:02
ir.cpp err
The initial program I tried to run:
```
pub fn main() -> %void {
var m2 = &2;
%%io.stdout.printf("hello: {}\n", m2);
}
```
error:
@cgag
cgag / richhickey.md
Created June 15, 2016 03:56 — forked from prakhar1989/richhickey.md
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 19:07 — forked from cespare/log.go
Golang apache logging
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 September 7, 2015 22:28
attemping to build neovim on void linux. Fixed by symlinking /bin/sh to bash
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

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.

@cgag
cgag / TrueColor.md
Last active August 29, 2015 14:18 — forked from XVilka/TrueColour.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"