Skip to content

Instantly share code, notes, and snippets.

View bwindels's full-sized avatar

Bruno Windels bwindels

View GitHub Profile
@bwindels
bwindels / gist:be9c6f89135cd574ae56
Created November 28, 2014 14:51
Generics for higher order functions
function map<I,O>(array:I[], mapper:(value:I) => O) : O[] {
var result:O[] = [];
var index = 0;
for(;index < array.length; ++index) {
result.push(mapper(array[index]));
}
return result;
}
function reduce<I,O>(array:I[], reducer:(reduced:O, value:I) => O, initialValue: O) : O {
@bwindels
bwindels / contentinputevent.html
Created October 8, 2015 13:50
Prototype of a restrictive contenteditable editor in JS/HTML
<!DOCTYPE html>
<html>
<body>
<p>The dog <span id="edit" contenteditable="true">sleeps on</span> the sofa</p>
<script type="text/javascript">
var handler = {
onBackspace: function() {
console.log("backspace");
},
@bwindels
bwindels / imagediff.html
Last active October 14, 2015 13:32
Tool to visualise difference between multiple images
<!DOCTYPE html>
<html>
<head>
<meta charset="utf8"/>
<style>
body {
font-family: Helvetica, Arial;
font-size: 12px;
}
@bwindels
bwindels / bitwise-not.rs
Last active April 8, 2016 13:18
Rust snippets
fn main() {
let a = 0b10010001u8;
let b = !a;
println!("{:08b}", a);
println!("{:08b}", b);
}
@bwindels
bwindels / 10_linux.patch
Created October 5, 2016 20:58
coreboot support for fedora grub config file script
*** 10_linux.orig 2016-10-05 22:46:49.564011135 +0200
--- 10_linux 2016-10-05 22:43:03.187055937 +0200
***************
*** 85,98 ****
--- 85,101 ----
version="$2"
type="$3"
args="$4"
+ bios_vendor=$(dmesg | grep -oP 'BIOS vendor:\s*\K([^;]+)')
sixteenbit=""

#Steps to update libreboot on my x200

For desired libreboot release, download:

  • libreboot rom for x200 with 8mb of flash
  • libreboot util

Flash new libreboot release

  • boot kernel once with params nopat iomem=relaxed so flashrom can mmap /dev/mem
  • cp .rom file for ukqwerty with vesafb to libreboot.rom

#Things to do after installing linux on x200 laptop

Low level tuning

pub trait WakeupChannel : Drop {
fn wakeup(&self)
}
pub trait WakeupBuilder {
fn create(callback: Fn<()>) -> WakeupChannel
}
mod apple {
@bwindels
bwindels / deserializer.rs
Last active September 28, 2017 15:39
Rust JSON parser with FieldRef
struct Foo<'a> {
age: u32,
name: &'a str,
}
pub enum FieldRef<'a, 'b: 'a> {
Str(&'a mut &'b str),
UInt32(&'a mut u32),
}
use std::cell::{RefCell, RefMut, BorrowMutError};
enum Event {
Click,
Close,
Keystroke
}
trait Child<'a> {
fn handle_event(&'a mut self, event: Event, ctx: &'a RefCell<u64>) -> u64;