Skip to content

Instantly share code, notes, and snippets.

Avatar

Erik Terpstra eterps

View GitHub Profile
@eterps
eterps / setup_sway
Created Dec 7, 2018
Install Sway (a tiling Wayland compositor) on Ubuntu
View setup_sway
#!/bin/bash
set -e
# Based on: https://gist.github.com/concatime/265fa14d260f3aa237ddf991d58dd639
mkdir /tmp/setup_sway
cd /tmp/setup_sway
# === Helpers ===
View domain_modeling.rs
#![allow(dead_code)]
#![allow(unused)]
fn main() {
let add1 = |x| x + 1; // signature is: fn(T) -> T
let add = |x, y| x + y; // signature is: fn(T, T) -> T
println!("{}", add1(2));
println!("{}", add(2, 3));
View typescript_equality.ts
type CustomerId = number
type OrderId = number
let customerId: CustomerId
let orderId: OrderId
customerId = 42
orderId = 42
if (customerId == orderId) {
View test.sh
#!/bin/bash
set -e
cat >fpstest.obn <<EOS
MODULE fpstest;
(*draw dots and print the number of displayed frames per second*)
IMPORT Input, Out, XYplane;
VAR
View Gfx.c
#include "SDL.h"
#include <stdbool.h>
#include <unistd.h>
SDL_Surface *screen;
SDL_Event event;
void Do(void) {
SDL_Init(SDL_INIT_VIDEO);
View Gfx.c
#include "SDL.h"
#include <stdbool.h>
#include <unistd.h>
SDL_Surface *screen;
SDL_Event event;
void Do(void) {
screen = SDL_SetVideoMode(640, 480, 16, SDL_SWSURFACE);
@eterps
eterps / rect.c
Last active Sep 9, 2018
Working SDL example
View rect.c
// gcc rect.c -o rect `sdl-config --cflags` `sdl-config --libs` && ./rect
// cflags: -I/usr/local/include/SDL -D_GNU_SOURCE=1 -D_THREAD_SAFE
// libs: -L/usr/local/lib -lSDLmain -lSDL -Wl,-framework,Cocoa
#include "SDL.h"
#include <stdbool.h>
#include <unistd.h>
SDL_Surface *screen;
@eterps
eterps / Gfx.c
Created Sep 9, 2018
obnc input focus issue
View Gfx.c
#include <obnc/OBNC.h>
#include ".obnc/Gfx.h"
#include <stdbool.h>
#include "SDL.h"
SDL_Surface *screen;
SDL_Event event;
void Gfx_Do_(void) {
SDL_Init(SDL_INIT_VIDEO);
@eterps
eterps / Dockerfile
Created Aug 27, 2018
ruby-llvm on ubuntu 16.04 with recent llvm version 3.5
View Dockerfile
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y build-essential ruby-dev llvm-3.5 wget
RUN gem install bundler rake
RUN /bin/echo -e "source 'https://rubygems.org'\ngem 'ruby-llvm'" >Gemfile
RUN bundle install
RUN wget -nv https://raw.githubusercontent.com/ruby-llvm/ruby-llvm/master/samples/hello.rb
CMD bundle exec ruby hello.rb
@eterps
eterps / Dockerfile
Created Aug 27, 2018
ruby-llvm on recent ubuntu with recent llvm version
View Dockerfile
FROM ubuntu:18.04
RUN apt-get update && apt-get install -y build-essential git ruby-dev llvm-5.0-dev
RUN gem install bundler rake
RUN /bin/echo -e "source 'https://rubygems.org'\ngem 'ruby-llvm', git: 'https://github.com/ruby-llvm/ruby-llvm', ref: '889e97d'" >Gemfile
RUN bundle install
CMD bundle exec ruby /var/lib/gems/*/bundler/gems/ruby-llvm*/samples/hello.rb