Skip to content

Instantly share code, notes, and snippets.

main::
mov 10000, $r12
mov 2, $r4
L26:
slt $r4, $r12, $r6
br $r6, L6
L5:
jmp main$exit
L6:
mov 2, $r1
EC10FC27 // mov 10000,$r12
E402F400 // mov 2,$r4
364C // slt $r4,$r12,$r6
D602 // br $r6,L6
C01D // jmp main$exit
E102F100 // mov 2,$r1
3714 // slt $r1,$r4,$r7
D70B // br $r7,L10
1341 // sub $r4,$r1,$r3
D304 // br $r3,L21
@ejrh
ejrh / colour_key_conversion_test.cpp
Last active August 29, 2015 14:20
Test case for a potention SDL2 bug when converting surfaces with colour keys
// TO COMPILE: gcc -o test colour_key_conversion_test.c -lSDL2
// AND RUN: ./test
#include <stdio.h>
#include <SDL2/SDL.h>
// smiley face image with transparency
unsigned short pixel_data[] = {
0xB54A, 0xB54A, 0xB54A, 0xB54A, 0xB54A,
Uint32 MESSAGE_EVENT = SDL_RegisterEvents(1);
/* In a thread dealing with network stuff */
while () {
shared_ptr<Message> message = read_message_from_network();
SDL_Event evt;
evt.type = MESSAGE_EVENT;
evt.user.data1 = // what?
build: " git 2016-01-03 00:51"
mods:
- xcom1
time:
year: 1999
minute: 6
weekday: 5
month: 1
hour: 16
day: 21
@ejrh
ejrh / bm.c
Created January 9, 2016 12:31
// Inspired by https://www.reddit.com/r/programming/comments/400wpy/andrei_alexandrescus_amazing_150_minutes_course/
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/resource.h>
#include <sys/times.h>
#include <time.h>
#define NUM_POWERS 19
-- Old table with types that are too big
create table forecast_base_0 (
key_id bigint not null,
time timestamp without timezone not null,
value double precision,
primary key (key_id, time)
);
-- New table with smaller types
create table forecast_base_1 (
CREATE TABLE forecast_base_0
(
nwp_analysis_at_date timestamp without time zone NOT NULL,
nwp_analysis_at_time_period smallint NOT NULL,
nwp_analysis_prognosis integer NOT NULL,
issued_prognosis integer NOT NULL,
valid_from_date timestamp without time zone NOT NULL,
valid_from_time_period smallint NOT NULL,
location_id bigint NOT NULL,
@ejrh
ejrh / gist:6e9c74bd65220fe656f8
Created March 22, 2016 08:33
Btree vs trigram index for short prefixes
filesys=# \d file
Table "public.file"
Column | Type | Modifiers
----------+-----------------------------+---------------------------------------------------
id | integer | not null default nextval('file_id_seq'::regclass)
name | character varying | not null
size | bigint | not null
modified | timestamp without time zone |
md5 | character(32) |
Indexes:
CREATE OR REPLACE FUNCTION public.forecast_base_1_part_trig_func()
RETURNS trigger AS
$BODY$
DECLARE
v_count int;
v_partition_name text;
v_partition_timestamp timestamptz;
BEGIN
IF TG_OP = 'INSERT' THEN
v_partition_timestamp := date_trunc('day', NEW.nwp_analysis_at_date);