Skip to content

Instantly share code, notes, and snippets.

@paulmoore
paulmoore / Animal.lua
Created December 4, 2011 07:06
A simple Class implementation in Lua for Object-Oriented Programming.
--- Animal.lua
--
-- A simple example of a base class usng the classes library.
--
-- @author PaulMoore
--
-- Copyright (C) 2011 by Strange Ideas Software
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
@tobyhede
tobyhede / postsql.sql
Created May 17, 2012 03:08
PostgreSQL as JSON Document Store
-- PostgreSQL 9.2 beta (for the new JSON datatype)
-- You can actually use an earlier version and a TEXT type too
-- PL/V8 http://code.google.com/p/plv8js/wiki/PLV8
-- Inspired by
-- http://people.planetpostgresql.org/andrew/index.php?/archives/249-Using-PLV8-to-index-JSON.html
-- http://ssql-pgaustin.herokuapp.com/#1
-- JSON Types need to be mapped into corresponding PG types
--
@mebens
mebens / gist:3929259
Created October 22, 2012 02:07
Generate a linear radial gradient in Love2D
local function scale(x, min1, max1, min2, max2)
return min2 + ((x - min1) / (max1 - min1)) * (max2 - min2)
end
local function distance(x1, y1, x2, y2)
return math.sqrt((x2 - x1) ^ 2 + (y2 - y1) ^ 2)
end
function radialGradient(radius)
local data = love.image.newImageData(radius * 2, radius * 2)
@dynajoe
dynajoe / Program.cs
Created November 1, 2012 16:06
Example C# HTTP Server
using System;
using System.Net;
using System.Text;
using System.Threading;
namespace ExampleSimpleWebserver
{
class Program
{
static void Main (string[] args)
@1wErt3r
1wErt3r / SMBDIS.ASM
Created November 9, 2012 22:27
A Comprehensive Super Mario Bros. Disassembly
;SMBDIS.ASM - A COMPREHENSIVE SUPER MARIO BROS. DISASSEMBLY
;by doppelganger (doppelheathen@gmail.com)
;This file is provided for your own use as-is. It will require the character rom data
;and an iNES file header to get it to work.
;There are so many people I have to thank for this, that taking all the credit for
;myself would be an unforgivable act of arrogance. Without their help this would
;probably not be possible. So I thank all the peeps in the nesdev scene whose insight into
;the 6502 and the NES helped me learn how it works (you guys know who you are, there's no
@chanks
chanks / gist:7585810
Last active June 22, 2024 19:01
Turning PostgreSQL into a queue serving 10,000 jobs per second

Turning PostgreSQL into a queue serving 10,000 jobs per second

RDBMS-based job queues have been criticized recently for being unable to handle heavy loads. And they deserve it, to some extent, because the queries used to safely lock a job have been pretty hairy. SELECT FOR UPDATE followed by an UPDATE works fine at first, but then you add more workers, and each is trying to SELECT FOR UPDATE the same row (and maybe throwing NOWAIT in there, then catching the errors and retrying), and things slow down.

On top of that, they have to actually update the row to mark it as locked, so the rest of your workers are sitting there waiting while one of them propagates its lock to disk (and the disks of however many servers you're replicating to). QueueClassic got some mileage out of the novel idea of randomly picking a row near the front of the queue to lock, but I can't still seem to get more than an an extra few hundred jobs per second out of it under heavy load.

So, many developers have started going straight t

@marijn
marijn / NOTES.markdown
Last active January 2, 2016 07:48
Notes I took while reading Priming Kanban by Jesper Boeg.

These are some thoughts on Kanban after reading [Priming Kanban][1].

Most important thing to remember:

#Kanban is a change method!#

Methodology Kind of process Change adoption
Plan Methodology Too much proces Resist change
Agile Just enough process Change is the fuel that keeps the engine running
@SeanCline
SeanCline / clone_ptr.h
Last active April 27, 2016 17:38
A quick (mostly untested) go at a `clone_ptr` implementation that keeps from slicing polymorphic objects by type erasing their copy constructor and storing them in the clone_ptr.
#pragma once
#include <memory>
#include <utility>
#include <type_traits>
#include <functional> // TODO: Stop using functional.
template <class T>
struct default_clone {
T* operator()(const T* ptr) const
@nwesterhausen
nwesterhausen / apprise_notify.sh
Created October 9, 2019 15:57
Apprise Notifier Script for Radarr/Sonarr/Lidarr
#!/bin/bash
###
# This script utilizes apprise (https://github.com/caronc/apprise) to send notifications
# You need to have apprise available for the user sonarr operates under.
# I installed it via `sudo pip install --system apprise` although the python
# community really dislikes it when you do that. Recommended installation would be
# something along the lines of:
#
# sudo su sonarr -s /bin/bash
# pip install --user apprise