Skip to content

Instantly share code, notes, and snippets.

@FeepingCreature
FeepingCreature / rulebritannia.sh
Created January 2, 2015 18:42
Replace the Factorio list of backers with a list of English towns.
#!/bin/sh
BACKERS=data/core/backers.json
BACKUP=data/core/backers.bak.json
if [ ! -f "$BACKUP" ]
then
echo "Backing up backers.json.."
mv "$BACKERS" "$BACKUP"
fi
echo "Replacing backers.json.."
(
module trainsearch;
void main() {
int[][] paths;
// There are only six paths through the
// intersection that a train can take.
/*
paths ~= [2];
paths ~= [3];
paths ~= [4];
@FeepingCreature
FeepingCreature / counter.vhd
Created April 23, 2015 07:08
vhdl vga sample
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
library altera;
use altera.altera_syn_attributes.all;
entity Counter is
generic (Size:Integer);
port (
Step, Reset: in std_logic;
[snip]
.text
.globl module_test7_add_of_function_to_sys_int_of_sys_int_and_sys_int
.type module_test7_add_of_function_to_sys_int_of_sys_int_and_sys_int, @function
module_test7_add_of_function_to_sys_int_of_sys_int_and_sys_int:
pushl %ebp
movl %esp, %ebp #mov4.2
.L106_entry:
pushl $0
movl 12(%esp), %eax #mov4.2
void sendPlayerPosLook(double x, y, z, float yaw, pitch, bool onGround) {
byte[auto~] data;
data ~= toField &x;
data ~= toField double:(y + 2);
data ~= toField &y;
data ~= toField &z;
data ~= toField &yaw;
data ~= toField &pitch;
data ~= *byte*:&onGround;
sendPacket(0x0d, data[]);
module tetris;
import sdl; // For graphics output
import std.math, std.file, std.random;
extern(C) int time(int*);
// Board size. size[0] is x is horizontal. size[1] is y is vertical.
alias size = (7, 14);
module pyramid;
import opengl, glsetup;
import sdl, camera;
import std.macros.switchover;
void main(string[] args) {
// resizeWindow (640, 480);
auto vertices = [vec3f (-1, -1, -1), vec3f(1, 1, 1)];
auto once-per(float t) {
auto lastrun = sec();
return new \(void delegate() task) {
auto sec = sec();
if (sec - lastrun > t) {
lastrun = sec;
task();
}
}
class Text : RectWidget, HasSizeInfo {
[...]
void setText(string s) {
provide "recomputes width";
[...]
class LinebreakText : RectWidget, HasSizeInfo {
[...]
void make-layout() {
auto mksphere(int depth) {
alias V = vec3f;
(V,V,V)[auto~] res;
if false return res[]; // return type hint
if (!depth) {
auto points = [for tup <- cross([-1, 1] x 3): V tup].eval[];
for auto tup <- [
(0, 1, 3), (0, 3, 2),
(4, 5, 7), (4, 7, 6),