Skip to content

Instantly share code, notes, and snippets.

View creationix's full-sized avatar
💚
<3

Tim Caswell creationix

💚
<3
View GitHub Profile
@lithdew
lithdew / main.zig
Last active January 23, 2024 03:51
zig: basic tcp echo server w/ stdlib event loop
const std = @import("std");
const os = std.os;
const net = std.net;
const mem = std.mem;
const log = std.log.scoped(.server);
const assert = std.debug.assert;
pub const io_mode = .evented;
const std = @import("std");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer std.debug.assert(gpa.deinit());
const allocator = &gpa.allocator;
const num_threads = std.math.max(1, (std.Thread.getCpuCount() catch 1) / 2);
const epolls = try allocator.alloc(std.os.fd_t, num_threads);
defer allocator.free(epolls);
@symisc
symisc / usage.html
Last active November 29, 2020 04:37
Usage example of the WebAssembly Real-Time face detector model - https://pixlab.io/downloads
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>WebAssembly Real-Time Face Detection</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
@mafintosh
mafintosh / c_ish.cc
Created November 28, 2017 18:47
Write native modules like you write C
#include <nan.h>
using namespace v8;
typedef struct {
int result;
int prev;
} fibo_t;
@creationix
creationix / storage.md
Last active December 21, 2018 03:18
Browser Storage Proposal

Level DB Style

This is highly influenced by https://github.com/google/leveldb#features

  • Keys and values are arbitrary byte arrays.
  • Data is stored sorted by key.
  • Callers can provide a custom comparison function to override the sort order.
  • The basic operations are Put(key,value), Get(key), Delete(key).
  • Multiple changes can be made in one atomic batch.
  • Users can create a transient snapshot to get a consistent view of data.
ul { padding: 0; margin: 0; }
li { list-style-type: none; font-family: sans-serif; padding: 0 1em; line-height: 2em;}
li:hover { background-color: #f95; }
.name { font-weight: bold;}
.type { opacity: 0.5; padding: 0 1em;}
.title { margin: 0.5em; font-size: 2em; }
.code { font-size: 16px; padding: 1em; font-family: "Ubuntu Mono", "DejaVu Sans Mono", "Liberation Mono", monospace;}
@creationix
creationix / shed.scad
Last active March 12, 2024 21:01
Shed design. Open in OpenScad to view 3d model.
windows = false; // show windows
stuff = false; // Show bikes, table, mower
l = 32; // Length of building in feet (16, 20, 24, 28, 32, ...)
h = 8*12-4.5+.5;
rl=6*12+1.375+.1; // cut to 73.5" long with 22.5 degree angles
tl = 68.7; // Used to tweak headers on top walls
// 2x6 concrete forms for foundation
// 10" wide grid
@tzudot
tzudot / lit.rb
Last active August 29, 2015 14:26 — forked from creationix/lit.rb
Homebrew
require "formula"
class Lit < Formula
homepage "https://github.com/luvit/lit"
url "https://lit.luvit.io/packages/luvit/lit/v2.1.11.zip"
sha1 "be0904957a4867bf1284d0ebd7b04e6ec521b85a"
depends_on "luvi" => :build
def install

Lisp syntax, but using whitespace to remove most parentheses.

  • Every line is wrapped as a list. Use do to get just the value.
  • Empty lines are ignored.
  • Indented lines are concatenated to their parent lists.
  • A pipe (|) acts like indentation without wasting whitespace.
  • Use square brackets for inline lists.
  • Use round parentheses for infix notation (first two items are swapped)

For example, take the following lisp style program:

@DamienCassou
DamienCassou / configuration.nix
Created October 22, 2014 13:41
configuration.nix file for NixOS on my macbook pro
{ config, pkgs, ... }:
let
hostname = "luz3";
in {
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
# I use VirtualBox to connect to Windows and Linux guests