Skip to content

Instantly share code, notes, and snippets.

🏳️‍🌈
Breaking things

Noel Cower nilium

🏳️‍🌈
Breaking things
Block or report user

Report or block nilium

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nicowilliams
nicowilliams / fork-is-evil-vfork-is-good-afork-would-be-better.md
Last active Jul 30, 2019
fork() is evil; vfork() is goodness; afork() would be better; clone() is stupid
View fork-is-evil-vfork-is-good-afork-would-be-better.md

I recently happened upon an implementation of popen() (different API, same idea) 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.

So here goes.

Long ago, I, like many Unix fans, thought that fork(2) and the fork-exec process spawning model were the greatest thing, and the Windows sucked for only having [exec*()](http://pubs.opengroup.org/onlinepubs/9699919

View list.md

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)
@nilium
nilium / binpack.cc
Last active Dec 12, 2015
Rudimentary tree packing class. Mainly intended for use with packing images for use in texture atlases. Uses pointers, so it's inherently evil.
View binpack.cc
// 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)
{}
@nilium
nilium / classes.lua
Created May 13, 2011
Hackjob class/inheritance/whatnot stuff for Lua
View classes.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:
View bmxparser.bmx
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:
View classes.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:
You can’t perform that action at this time.