Skip to content

Instantly share code, notes, and snippets.

@Tetralux
Tetralux / tiny.zig
Last active March 11, 2023 10:37
A simple example of a calculator programming language that compiles to native code!
//
// A simple example of a calculator programming language, that compiles to native code!
//
// Written by Tetralux <tetraluxonpc@gmail.com>, 2023-03-09.
//
// Programs are a string that you pass as an argument in the form of a mathmetical expression.
// e.g: '10 + 4 - 1 + 7'.
// This program will generate some Zig code that computes the answer, and prints it to stdout.
// It then will invoke the Zig compiler as a subprocess to compile and run this program.
//
@doccaico
doccaico / main.zig
Last active March 25, 2024 16:00
Conway's Game of Life
// Build: zig build-exe -O ReleaseFast --strip src/main.zig
// Run: zig build run -- -w 70 -h 40 -m "*" -s 0.07 -c 25
// Version: 0.10.0-dev.3475+b3d463c9e
// Date: 2022/08/09
const std = @import("std");
const fmt = std.fmt;
const mem = std.mem;
const os = std.os;
@LewisGaul
LewisGaul / zig-blog-posts.md
Last active March 28, 2024 06:53
Collection of blog posts about the Zig programming language
@fvclaus
fvclaus / README.md
Last active January 8, 2024 16:16
Run vscode tasks with nvm

Nvm does not work in vscode tasks, because tasks are run without a shell. .bashrc is not loaded and the nvm command is unknown.

My solution uses a wrapper script around /bin/bash that reads in the correct node version from .npmrc in the project folder.

#!/bin/bash

set -e

if [[ "$2" == nvm* ]]; then

export NODE_VERSION=v$(cat .nvmrc)

@JoelQ
JoelQ / elm-types-glossary.md
Last active February 14, 2024 14:29
Elm Type Glossary

Elm Types Glossary

There's a lot of type terminology and jargon going around when discussing types in Elm. This glossary attempts to list some of the most common type terms along with synonyms, terms from other language communities, examples, and links to more detailed articles on each topic.

@jan-warchol
jan-warchol / sync-history.sh
Last active February 4, 2024 04:52
Synchronize history across bash sessions
# Synchronize history between bash sessions
#
# Make history from other terminals available to the current one. However,
# don't mix all histories together - make sure that *all* commands from the
# current session are on top of its history, so that pressing up arrow will
# give you most recent command from this session, not from any session.
#
# Since history is saved on each prompt, this additionally protects it from
# terminal crashes.
@bgourlie
bgourlie / mortality.md
Last active December 2, 2017 21:54
Interpreting DUSCMPUB-formatted mortality data

Interpreting mortality data in DUSCMPUB format

This gist explains how to interpret the DUSCMPUB-formatted mortality data found [here][1] in conjunction with the [reference PDF][2].

The [reference PDF][2] uses 3 components to describe the type of data, its location within the row, and its size:

  • data item: A specific datapoint, for example, a value representing the highest completed level of education.
  • tape location: The column within the line where a data item is located. Each character in a line represents a column, with each line having 472 columns.
  • size: The number of columns used to represent a particular data item.
@evancz
evancz / data-interchange.md
Last active April 12, 2024 08:39
Why do I have to write JSON decoders in Elm?

A vision for data interchange in Elm

How do you send information between clients and servers? What format should that information be in? What happens when the server changes the format, but the client has not been updated yet? What happens when the server changes the format, but the database cannot be updated?

These are difficult questions. It is not just about picking a format, but rather picking a format that can evolve as your application evolves.

Literature Review

By now there are many approaches to communicating between client and server. These approaches tend to be known within specific companies and language communities, but the techniques do not cross borders. I will outline JSON, ProtoBuf, and GraphQL here so we can learn from them all.

@bangonkali
bangonkali / symlink.sh
Created August 9, 2016 15:03
Creating a symlink for visual studio code on mac os x el capitan
@yang-wei
yang-wei / destructuring.md
Last active February 20, 2024 04:40
Elm Destructuring (or Pattern Matching) cheatsheet

Should be work with 0.18

Destructuring(or pattern matching) is a way used to extract data from a data structure(tuple, list, record) that mirros the construction. Compare to other languages, Elm support much less destructuring but let's see what it got !

Tuple

myTuple = ("A", "B", "C")
myNestedTuple = ("A", "B", "C", ("X", "Y", "Z"))