Skip to content

Instantly share code, notes, and snippets.

View mpasternacki's full-sized avatar

Maciej Pasternacki mpasternacki

View GitHub Profile
@mpasternacki
mpasternacki / flakes.py
Created May 25, 2010 12:41
Django management command to run pyflakes against Django project
from django.conf import settings
from django.core.management.base import BaseCommand
#### pyflakes.scripts.pyflakes, modified:
## - return array of warnings instead of printing them
## - honour pyflakes:ignore comments
import compiler, sys
import os
import pyflakes.checker
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) ]
@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'))
@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 / 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:
#
#!/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 / override_print.py
Created June 8, 2012 17:24
Track down Python print statements that clutter your output.
# Trace 'print' statement calls cluttering your test suite output.
#
# It is not that simple to track 'print' statement in Python 2.x - it
# cannot be monkey-patched itself, because it's not a function. So we
# override sys.stdout and check the backtrace when stdout is written
# to.
#
# The overload happens only if TRACE_PRINT environment variable is
# set. By default, only the offending file name and line number is
# printed; if TRACE_PRINT environment variable is set to 'traceback',
@mpasternacki
mpasternacki / README.md
Last active January 18, 2018 10:56
A Continuous Packaging Pipeline: The Materials

A Continuous Packaging Pipeline

A list of tools mentioned in my Ignite talk from Devopsdays Rome 2012 on a continuous packaging pipeline, with links and short description for each tool.

The talk slides are at https://speakerdeck.com/mpasternacki/a-continuous-packaging-pipeline; a longer blog post will be written soon.

Vendorificator

Available at https://github.com/3ofcoins/vendorificator/ or with gem install vendorificator

Include third party modules in your git repo, using pristine branches to sanely maintain local changes, upgrades, and merges.

#[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();
}
@mpasternacki
mpasternacki / data_bag_from_yaml.rb
Created August 19, 2011 17:39
Knife plugin to create data bags from YAML files
#
# Author:: Maciej Pasternacki (<maciej@pasternacki.net>)
# Copyright:: Copyright (c) 2010 Maciej Pasternacki
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0