Skip to content

Instantly share code, notes, and snippets.

// Largely copied (with some modernisation applied) from:
// https://github.com/reem/rust-lazy/blob/master/src/single.rs
use std::cell::UnsafeCell;
use std::ptr;
use std::ops::{Deref, DerefMut};
use self::Inner::{Evaluated, EvaluationInProgress, Unevaluated};
pub trait Invoke<A = (), R = ()> {

Notes: Arch Linux on Chromebook Pixel 2015

To install another OS, follow the instructions at https://www.chromium.org/chromium-os/developer-information-for-chrome-os-devices/chromebook-pixel-2015 to enable developer mode, after which you should be able to hit Ctrl+L on the boot screen to launch SeaBIOS, which will boot external media (BIOS only, not GPT). You’ll be able to boot the Arch installation image from a USB stick using this.

Currently, I’ve got GRUB running off an SD card, which I boot using SeaBIOS. My system is installed on the internal drive, but GRUB won’t work from there. My technique at https://gist.github.com/bodil/b14a398189e5643ee03e has so far failed to yield a booting kernel on the internal drive, which is somewhat annoying, but as I keep the SD card permanently inserted anyway, it hasn’t been bothersome.

Arch has a wiki page on the Pixel 2015: https://wiki.archlinux.org/index.php/Chromebook_Pixel_2

The stock kernel (as of 4.0.5) lacks support for some h

@bodil
bodil / wat.ts
Created January 16, 2014 22:36
Don't.
/**
* Magic version of Rx.Observable.sync() that allows for adding more
* Observables to the input feed while processing.
*
* Needs a more descriptive name maybe.
*/
function wat<T,U>(initialState: T, initialFeeds: Rx.IObservable<U>[], iterator: (state: T, e: U) => StateChange<T,U>): any {
var sub = new Rx.BehaviorSubject(initialState);
var state = initialState;
@bodil
bodil / webbit.clj
Created September 26, 2013 17:21
Basic Webbit adapter for Ring.
(ns ring.adapter.webbit
(:require [clojure.string :as s]
[clojure.java.io :as io])
(:import [org.webbitserver WebServer WebServers HttpHandler]
[java.io File InputStream]))
(defn- transform-headers [headers]
(apply hash-map (mapcat (fn [e] [(s/lower-case (.getKey e))
(.getValue e)]) headers)))
@bodil
bodil / README.md
Last active December 20, 2015 11:08
The core.async exercise from the July 30th London Clojure Dojo

core.async example thing

To run:

  • checkout https://github.com/clojure/core.async and install it using lein install
  • make a project directory for this code
  • put omgcoreasync.cljs in a src subdirectory, project.clj and index.html in the root
  • go lein cljsbuild once to build
  • load index.html in a browser and watch it go
@bodil
bodil / addagram.clj
Created April 1, 2012 00:19
Clojure solution for http://addagram.mytestbench.com/ with ~1s execution time.
(ns addagram.core
(:use [clojure.test]
[clojure.java.io :only [reader]]))
(with-test
(defn sort-largest [l]
(sort-by #(- (count %)) l))
(is (= ["blerk" "quux" "foo" "bar"]
(sort-largest ["foo" "quux" "bar" "blerk"]))))
@bodil
bodil / anagram.clj
Created March 5, 2012 16:03
Anagram-kata
(ns ohai
(:use clojure.test))
(def words
'("foo"
"rab"
"rba"))
(with-test
(defn anagram? [a b]
(ns lol
(:use clojure.test))
(def board [[nil :mine nil nil ]
[:mine nil nil nil ]
[nil nil :mine nil ]
[:mine nil nil :mine]])
(defn y [c] (c 0))
(defn x [c] (c 1))
(ns lol
(:use clojure.test))
(def board [nil :bomb nil nil
:bomb nil nil nil
nil nil :bomb nil
:bomb nil nil :bomb])
(with-test
(defn bomb?
@bodil
bodil / extremestartup.coffee
Created August 19, 2011 08:05
A CoffeeScript solution for @jhannes's evil Extreme Startup question set
# To install dependencies:
# $ npm install express mongoose connect-mongoose
fs = require "fs"
express = require 'express'
mongoose = require 'mongoose'
sessionStore = require("connect-mongoose")(express)
Schema = mongoose.Schema
mongo_uri = "mongodb://localhost/bodilpwnz"