Skip to content

Instantly share code, notes, and snippets.

@jsimmons
jsimmons / data.csv
Created April 21, 2017 01:28
Another ridiculously over-engineered interview question answered in Rust. This time from https://medium.com/@rodbegbie/find-open-restaurants-an-engineering-take-home-test-dissected-1ada20282ceb
Kushi Tsuru Mon-Sun 11:30 am - 9 pm
Osakaya Restaurant Mon-Thu, Sun 11:30 am - 9 pm / Fri-Sat 11:30 am - 9:30 pm
The Stinking Rose Mon-Thu, Sun 11:30 am - 10 pm / Fri-Sat 11:30 am - 11 pm
McCormick & Kuleto's Mon-Thu, Sun 11:30 am - 10 pm / Fri-Sat 11:30 am - 11 pm
Mifune Restaurant Mon-Sun 11 am - 10 pm
The Cheesecake Factory Mon-Thu 11 am - 11 pm / Fri-Sat 11 am - 12:30 am / Sun 10 am - 11 pm
New Delhi Indian Restaurant Mon-Sat 11:30 am - 10 pm / Sun 5:30 pm - 10 pm
Iroha Restaurant Mon-Thu, Sun 11:30 am - 9:30 pm / Fri-Sat 11:30 am - 10 pm
Rose Pistola Mon-Thu 11:30 am - 10 pm / Fri-Sun 11:30 am - 11 pm
Alioto's Restaurant Mon-Sun 11 am - 11 pm
@jsimmons
jsimmons / data.csv
Created April 21, 2017 01:28
Another ridiculously over-engineered interview question answered in Rust.
Osakaya Restaurant Mon-Thu, Sun 11:30 am - 9 pm / Fri-Sat 11:30 am - 9:30 pm
The Stinking Rose Mon-Thu, Sun 11:30 am - 10 pm / Fri-Sat 11:30 am - 11 pm
McCormick & Kuleto's Mon-Thu, Sun 11:30 am - 10 pm / Fri-Sat 11:30 am - 11 pm
Mifune Restaurant Mon-Sun 11 am - 10 pm
The Cheesecake Factory Mon-Thu 11 am - 11 pm / Fri-Sat 11 am - 12:30 am / Sun 10 am - 11 pm
New Delhi Indian Restaurant Mon-Sat 11:30 am - 10 pm / Sun 5:30 pm - 10 pm
Iroha Restaurant Mon-Thu, Sun 11:30 am - 9:30 pm / Fri-Sat 11:30 am - 10 pm
Rose Pistola Mon-Thu 11:30 am - 10 pm / Fri-Sun 11:30 am - 11 pm
Alioto's Restaurant Mon-Sun 11 am - 11 pm
@jsimmons
jsimmons / trie.rs
Created April 10, 2017 09:01
A half baked rust version of Hybernating Rhinos' interview question. https://ayende.com/blog/174049/the-low-level-interview-question
use std::fs::File;
use std::io::BufReader;
use std::io::Read;
use std::io::Write;
use std::result;
use std::mem::transmute;
use std::mem::size_of;
const TRIE_SIZE: usize = 32768;
@jsimmons
jsimmons / bork.rs
Last active March 28, 2017 03:40
Writing some Stupid Stuff in rust for giggles.
use std::iter::Peekable;
use std::str::FromStr;
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
struct Atom(usize);
struct StringPool {
symbols: Vec<String>
}
@jsimmons
jsimmons / serialise.rs
Last active January 29, 2017 13:15
Playing with Glen Fiedler's packet serialisation approach in Rust
pub struct RigidBody {
x: f32,
y: f32,
}
impl Serialize for RigidBody {
fn serialize<T: BitStream>(&mut self, stream: &mut T) -> Result {
stream.stream_f32(&mut self.x).unwrap();
stream.stream_f32(&mut self.y).unwrap();
Ok(())
@jsimmons
jsimmons / obj.c
Last active August 11, 2017 18:20
I presume this is how I did it last time...
typedef float f;typedef int i;
f t[2<<15];
void parse_obj() {
f *l=t;i c;while((c=getchar())!=EOF)if((c=='v'||c=='f')&&scanf(" %f %f %f\n",l,l+1,l+2)==3)if(c=='v')l+=3;else{
I k=(I){*l,*(l+1),*(l+2)};
printf("FACE (%f, %f, %f), (%f, %f %f), (%f, %f, %f)\n",
t[k.x*3],t[k.x*3+1],t[k.x*3+2],
t[k.y*3],t[k.y*3+1],t[k.y*3+2],
t[k.z*3],t[k.z*3+1],t[k.z*3+2]);
@jsimmons
jsimmons / blah.glsl
Last active September 22, 2016 08:45
https://www.shadertoy.com/view/ltK3D1
@jsimmons
jsimmons / lel_demo.c
Created April 5, 2016 10:24
GLFAST + MINIMAL GL
#include <stdint.h>
#include <stdbool.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/XKBlib.h>
#include <dlfcn.h>
#include <stdio.h>
#include <sys/syscall.h>
#include <time.h>
@jsimmons
jsimmons / resize.c
Created October 4, 2014 05:38
Resize Cursors SDL
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"
#define STBIR_NO_ALPHA_EPSILON
#define STB_IMAGE_RESIZE_IMPLEMENTATION
#include "stb_image_resize.h"
#include <stdbool.h>
@jsimmons
jsimmons / demo.c
Last active August 7, 2023 03:49
Minimal OpenGL X11 Demo Linux
#include <stdint.h>
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
#include <GL/glx.h>
#include <GL/gl.h>
#include <dlfcn.h>
#include <stdio.h>
#include <sys/syscall.h>
#include <time.h>