Skip to content

Instantly share code, notes, and snippets.

View mpasternacki's full-sized avatar

Maciej Pasternacki mpasternacki

View GitHub Profile
#[task(resources=[i2c])]
fn init_display(cx: init_display::Context) {
let lcd = cx.resources.i2c.lcd_mut();
lcd.init(2, 16).unwrap();
lcd.backlight(true).unwrap();
lcd.home().unwrap();
uwrite!(lcd, "Hello?").ok();
}
xkb_keymap {
xkb_keycodes { include "xfree86+aliases(qwerty)" };
xkb_types { include "complete" };
xkb_compat { include "complete" };
xkb_symbols {
include "pc+pl+ctrl(swap_lwin_lctl)+ctrl(swap_rwin_rctl)"
replace key <UP> {
type[Group1]= "THREE_LEVEL",
symbols[Group1]= [ Up, Up, NoSymbol ],
actions[Group1]= [ NoAction(), NoAction(), RedirectKey(key=<PGUP>, clearMods=Mod5) ]

Keybase proof

I hereby claim:

  • I am mpasternacki on github.
  • I am mpasternacki (https://keybase.io/mpasternacki) on keybase.
  • I have a public key whose fingerprint is 5810 5238 081B 0C33 46BF A0F5 A43B 1DDA E9A0 8CCF

To claim this, I am signing this object:

@mpasternacki
mpasternacki / freebsd_on_mbp.md
Created January 23, 2015 17:12
FreeBSD on a MacBook Pro

FreeBSD on a MacBook Pro

Since 2008 or 2009 I work on Apple hardware and OS: back then I grew tired of Linux desktop (which is going to be MASSIVE NEXT YEAR, at least since 2001), and switched to something that Just Works. Six years later, it less and less Just Works, started turning into spyware and nagware, and doesn't need much less maintenance than Linux desktop — at least for my work, which is system administration and software development, probably it is better for the mythical End User person. Work needed to get software I need running is not less obscure than work I'd need to do on Linux or othe Unix-like system. I am finding myself turning away from GUI programs that I used to appreciate, and most of the time I use OSX to just run a terminal, Firefox, and Emacs. GUI that used to be nice and unintrusive, got annoying. Either I came full circle in the last 15 years of my computer usage, or the OSX experience degraded in last 5 years. Again, this is from a sysadmin/developer ki

@mpasternacki
mpasternacki / git-pass.sh
Last active January 11, 2020 22:56
Use multiple git-managed http://www.passwordstore.org/ stores
#!/bin/sh
set -e
# git-pass
# ========
# This script allows easy usage of http://www.passwordstore.org/ with
# multiple, Git-managed stores. It works both as self-standing shell
# script (that can be committed to the repository itself), or as a Git
# subcommand (in which case it should reside somewhere in $PATH or in
@mpasternacki
mpasternacki / docker-compile.pl
Last active March 23, 2020 14:05
Perl script to build a Docker image from Dockerfile that creates the image in a single layer, without any intermediate images. Needs JSON CPAN module (available as `libjson-perl` Debian/Ubuntu package). Usage: run the script in the directory that contains a Dockerfile. More details in a blog post: http://3ofcoins.net/2013/09/22/flat-docker-images/
#!/usr/bin/env perl
use feature 'switch';
use strict;
use warnings;
use Data::Dumper;
use File::Basename;
use File::Copy;
use File::Path qw/make_path/;
#!/usr/bin/env python
import json
import sys
def pp(vv, prefix='$'):
if isinstance(vv, (list,tuple)):
for i, v in enumerate(vv):
pp(v, "{0}[{1}]".format(prefix, i))
elif isinstance(vv, dict):
@mpasternacki
mpasternacki / bundle-activate.sh
Created May 28, 2013 10:11
Script to activate Ruby Gem Bundler environment in current shell session.
#!/bin/sh
#
# This script activates a Gem Bundler environment in current shell
# session. This lets you type commands without `bundle exec` all the
# time, even if you leave the project's directory, and without complex
# magic that runs with every command.
#
# Usage: save this file somewhere. Use following command to activate
# current directory's bundle in current shell session:
#
@mpasternacki
mpasternacki / runner.pl
Last active December 16, 2015 03:39
A runner script to run any command and save its stdout and stderr in a timestamped log file, ready to be harvested by Logstash. Adds JSON metadata, and optionally locks the command, ensuring it doesn't run in multiple copies at the same time.
#!/usr/bin/env perl -w
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
#
# Copyright (C) 2013 Maciej Pasternacki <maciej@pasternacki.net>
#
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document, and changing it is allowed as long
# as the name is changed.
@mpasternacki
mpasternacki / soup_download.rb
Last active December 15, 2015 09:39
Download lolcats from your soup.io while it's up! Needs Ruby (used with MRI - "the regular ruby" - 1.9.3, should work with 1.9.2 or 2.0.0; 1.8.7 is a "maybe") and the Nokogiri gem (http://nokogiri.org).
require 'fileutils'
require 'open-uri'
require 'yaml'
require 'rubygems'
require 'nokogiri'
FileUtils.mkdir_p 'items'
feed = Nokogiri::XML(File.open('3fc1319c496ea1aacde451cecbdc17e3.rss'))