Skip to content

Instantly share code, notes, and snippets.

View nilium's full-sized avatar
🍉
internal screaming intensifies

Noel nilium

🍉
internal screaming intensifies
View GitHub Profile
@nilium
nilium / classes.lua
Created May 13, 2011 20:29
Hackjob class/inheritance/whatnot stuff for Lua
--[[
Copyright (c) 2009 Noel R. Cower
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Rem
Copyright (c) 2010 Noel R. Cower
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
@nilium
nilium / binpack.cc
Last active December 12, 2015 03:18
Rudimentary tree packing class. Mainly intended for use with packing images for use in texture atlases. Uses pointers, so it's inherently evil.
// binpack.cc -- Noel Cower -- Public Domain
#include "binpack.hh"
namespace snow
{
binpack_t::binpack_t(const recti_t &frame, binpack_t *right, binpack_t *bottom) :
pack_right_(right), pack_bottom_(bottom), frame_(frame), loaded_(false)
{}
--[[
Copyright (c) 2009 Noel R. Cower
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@cite-reader
cite-reader / history-of-password-storage.md
Last active July 9, 2020 18:24
An oral history of password storage

This oral his­to­ry of pass­word stor­age on the Web orig­i­nal­ly ap­peared as a re­mark in the #in­fos­ec chan­nel of the Hang­ops slack—the con­ver­sa­tion had turned to a men­tion of “hashed, salt­ed pass­words” in a breach an­nounce­ment in a way that made me sus­pect at least some of our friends had not stud­ied the top­ic in de­tail. Sev­er­al par­tic­i­pants then en­cour­aged me to ex­pand the re­mark into a blog post, and now here we are.While I was around for some of this, much of it pre­dates my ca­reer; every­thing is as ac­cu­rate as I can rea­son­ably make it, but cor­rec­tions of gross er­rors are wel­comed.The first time peo­ple at­tempt to de­sign a Web lo­gin sys­tem, they will usu­al­ly de­fault to sim­ply in­sert­ing their users’ pass­words in their data­base. This so­lu­tion is sim­ple, ob­vi­ous, and wrong.The prob­lem is that data­base stor­age is not near­ly as pri­vate as we would all like it to be. Even the data­bas­es that we’d

@nilium
nilium / cleanroom
Created January 10, 2020 23:28
Script to run a shell or command in a clean, temporary copy of a repository.
#!/usr/bin/env bash
# cleanroom: run a command or shell in a clean, temporary copy of a repository.
case "$1" in
-h|-help|--help)
cat <<'USAGE'
Usage: cleanroom [-h|-help|--help] [CMD...]
Execute a command in a clone of the current repository, made under
a temporary directory.

Are there other single-file public-domain libraries out there?

Yes. Here are some:

  • jo_gif.cpp: tiny GIF writer (public domain)
  • gif.h: animated GIF writer (public domain)
  • tiny_jpeg.h: JPEG encoder (public domain)
  • lodepng: PNG encoder/decoder (zlib license)
  • nanoSVG: 1-file SVG parser; 1-file SVG rasterizer (zlib license)
  • tinyobjloader: wavefront OBJ file loader (BSD license)
@nicowilliams
nicowilliams / fork-is-evil-vfork-is-good-afork-would-be-better.md
Last active November 5, 2023 12:14
fork() is evil; vfork() is goodness; afork() would be better; clone() is stupid

I recently happened upon a very interesting implementation of popen() (different API, same idea) called popen-noshell using clone(2), and so I opened an issue requesting use of vfork(2) or posix_spawn() for portability. It turns out that on Linux there's an important advantage to using clone(2). I think I should capture the things I wrote there in a better place. A gist, a blog, whatever.

This is not a paper. I assume reader familiarity with fork() in particular and Unix in general, though, of course, I link to relevant wiki pages, so if the unfamiliar reader is willing to go down the rabbit hole, they should be able to come ou