Skip to content

Instantly share code, notes, and snippets.

[ 0.000000] x86/PAT: Configuration [0-7]: WB WT UC- UC WC WP UC UC
[ 0.000000] Initializing cgroup subsys cpuset
[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Initializing cgroup subsys cpuacct
[ 0.000000] Linux version 4.2.0-18-generic (buildd@lgw01-38) (gcc version 5.2.1 20151010 (Ubuntu 5.2.1-22ubuntu2) ) #22-Ubuntu SMP Fri Nov 6 18:25:50 UTC 2015 (Ubuntu 4.2.0-18.22-generic 4.2.3)
[ 0.000000] Command line: placeholder root=UUID=f3feacbe-ef73-430f-937d-e1232da77e68 ro rootflags=subvol=@ quiet splash pci=biosirq
[ 0.000000] KERNEL supported cpus:
[ 0.000000] Intel GenuineIntel
[ 0.000000] AMD AuthenticAMD
[ 0.000000] Centaur CentaurHauls
[ 0.000000] x86/PAT: Configuration [0-7]: WB WT UC- UC WC WP UC UC
[ 0.000000] Initializing cgroup subsys cpuset
[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Initializing cgroup subsys cpuacct
[ 0.000000] Linux version 4.2.0-18-generic (buildd@lgw01-38) (gcc version 5.2.1 20151010 (Ubuntu 5.2.1-22ubuntu2) ) #22-Ubuntu SMP Fri Nov 6 18:25:50 UTC 2015 (Ubuntu 4.2.0-18.22-generic 4.2.3)
[ 0.000000] Command line: placeholder root=UUID=f3feacbe-ef73-430f-937d-e1232da77e68 ro rootflags=subvol=@ quiet splash acpi=off
[ 0.000000] KERNEL supported cpus:
[ 0.000000] Intel GenuineIntel
[ 0.000000] AMD AuthenticAMD
[ 0.000000] Centaur CentaurHauls
import sys
import os
# This is basically shutil.copyfileobj, but ignoring IO errors when reading.
# After doing a simple experiment with btrfs checksumming, I wondered if it was possible
# to still read a file that gave error with `cp`. The answer is obviously yes, since
# the checksum errors will work at the block-level (thus, why the chunksize is bsize)
# If you actually want to recover corrupted files from btrfs, without having to restore
# every single file in the fs, you might want to use instead:
import json
from collections import namedtuple
Duh = namedtuple('Duh', 'foo bar')
json.loads('{"foo":1, "bar":2}', object_hook=lambda x: Duh(**x))
@berdario
berdario / cabal.config
Created October 12, 2015 10:31
Hackage server cabal.config (generated from `stack list-dependencies` and manually adding packages whose version was unknown)
constraints: Cabal ==1.22.4.0,
HStringTemplate ==0.8.3,
HTTP ==4000.2.20,
HUnit ==1.3.0.0,
HaXml ==1.25.3,
QuickCheck ==2.8.1,
SHA ==1.6.4.2,
acid-state ==0.13.0,
aeson ==0.10.0.0,
ansi-terminal ==0.6.2.3,
@berdario
berdario / cabal.config
Created October 12, 2015 10:30
Hackage-server cabal freeze
constraints: Cabal ==1.22.4.0,
HStringTemplate ==0.8.3,
HTTP ==4000.2.20,
HaXml ==1.25.3,
QuickCheck ==2.8.1,
SHA ==1.6.4.2,
acid-state ==0.13.0,
aeson ==0.10.0.0,
ansi-terminal ==0.6.2.3,
appar ==0.1.4,
from functools import singledispatch
from collections import Iterable
from json import JSONEncoder, dumps
json_converter = singledispatch(JSONEncoder().default)
json_converter.register(Iterable)(list)
class A:
def __init__(self, a, b):
@berdario
berdario / fbchatfix.user.js
Created July 26, 2011 15:34
fbchatfix chrome userscript
// ==UserScript==
// @name fbchatfix
// @match http://*.facebook.com/*
// @match https://*.facebook.com/*
// ==/UserScript==
function addfix() {
var script = document.createElement("script");
script.setAttribute("type","text/javascript");
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE GADTs #-}
module Models where
import Database.Persist.Sqlite (runSqlite)
-- without the explicit type signature, it fails
-- with an ambiguous Control.Monad.IO.Class.MonadIO instance
{-# LANGUAGE ScopedTypeVariables #-}
import System.Environment (getArgs, getEnv)
import Control.Exception (catch, SomeException)
import Data.Map.Strict (fromList, lookup, findWithDefault, insert, assocs)
import Prelude hiding (lookup)
partitionPairs' Nothing ys (x:xs) = partitionPairs' (Just x) ys xs
partitionPairs' Nothing ys [] = ys
partitionPairs' (Just x) ys (y:xs) = partitionPairs' Nothing ((x,y):ys) xs