Skip to content

Instantly share code, notes, and snippets.

@stanislaw
stanislaw / build-report.groovy
Created June 10, 2016 10:07 — forked from x-cray/build-report.groovy
Jenkins email-ext plugin groovy template. Generates build report. Based on http://techkriti.wordpress.com/2008/08/30/using-groovy-with-hudson-to-send-rich-text-email/
<!DOCTYPE html>
<head>
<title>Build report</title>
<style type="text/css">
body
{
margin: 0px;
padding: 15px;
}
@stanislaw
stanislaw / ddd.md
Created June 27, 2016 19:56 — forked from zsup/ddd.md
Documentation-Driven Development (DDD)

Documentation-Driven Development

The philosophy behind Documentation-Driven Development is a simple: from the perspective of a user, if a feature is not documented, then it doesn't exist, and if a feature is documented incorrectly, then it's broken.

  • Document the feature first. Figure out how you're going to describe the feature to users; if it's not documented, it doesn't exist. Documentation is the best way to define a feature in a user's eyes.
  • Whenever possible, documentation should be reviewed by users (community or Spark Elite) before any development begins.
  • Once documentation has been written, development should commence, and test-driven development is preferred.
  • Unit tests should be written that test the features as described by the documentation. If the functionality ever comes out of alignment with the documentation, tests should fail.
  • When a feature is being modified, it should be modified documentation-first.
  • When documentation is modified, so should be the tests.
@stanislaw
stanislaw / States-v2.md
Created July 28, 2016 19:16 — forked from andymatuschak/States-v3.md
A composable pattern for pure state machines with effects (draft v2)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

@stanislaw
stanislaw / gist:3e71034dc68dee774218c9e4f2c60830
Created September 14, 2016 14:27 — forked from ericallam/gist:11214298
Fixing animation snapback without setDisableActions:YES
// Implements the solution for solving "snapback" found in
// Chapter 8 of "iOS Core Animation Advanced Techniques" by Nick Lockwood
// without the need to use setDisableActions: to override the implicit animation,
// instead passing in the implicit animation key in addAnimation:forKey:
// With setDisableActions
- (void)applyBasicAnimation:(CABasicAnimation *)animation toLayer:(CALayer *)layer
{
//set the from value (using presentation layer if available)
animation.fromValue = [layer.presentationLayer ?: layer valueForKeyPath:animation.keyPath];
#!/bin/sh
#
# Converts branch name 'MAPP-452_how-is-it-going' into a commit message 'MAPP-452 How is it going'
#
if ! [ -z $2 ]
then
if ! [ "message" == $2 ]
then
@stanislaw
stanislaw / mutation_testing_implementation_notes.md
Created June 7, 2017 13:28 — forked from hcoles/mutation_testing_implementation_notes.md
So you want to build a mutation testing system

So you want to build a mutation testing system

Introduction

There have been a lot mutation testing systems, but very few have them have seen succesfull use in industry.

This document is a set of notes that might be helpful for anyone thinking of implementing a mutation testing system for another language.

It represents some of the things we learnt while creating pitest. The choices made by pitest are not neccessarily the best choices for your system. Some of these choices are appropriate only because of the particular quirks of Java and the JVM, and some of them are simply the first idea that we had.

@stanislaw
stanislaw / runtime-class.m
Created February 14, 2018 16:42 — forked from mikeash/runtime-class.m
Creating a usable class purely at runtime using the Objective-C runtime APIs.
// clang -fobjc-arc -framework Foundation runtime-class.m
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
@interface Person : NSObject
- (id)initWithFirstName: (NSString *)firstName lastName: (NSString *)lastName age: (NSUInteger)age;
@stanislaw
stanislaw / Communicator.h
Created February 15, 2018 14:07 — forked from rjungemann/Communicator.h
How to open a TCP socket in Objective-C
#import <Foundation/Foundation.h>
@interface Communicator : NSObject <NSStreamDelegate> {
@public
NSString *host;
int port;
}
- (void)setup;
@stanislaw
stanislaw / wrapfigure_without_whitespace.tex
Created October 6, 2018 17:31 — forked from yig/wrapfigure_without_whitespace.tex
Eliminate white space around wrapfigure environments in LaTeX.
%% The typical answer for how to eliminate white space in wrapfigure doesn't work for me (I'm using a SIGGRAPH style sheet):
%% http://tex.stackexchange.com/questions/111393/too-much-space-around-wrap-figure
%% Instead, let's just offset the image.
%% The horizontal white space is \columnsep and the vertical white space is \intextsep.
%% Subtract them from the column width and offset the image accordingly.
%% How to move an image:
%% http://tex.stackexchange.com/questions/107340/how-to-shift-graphics-adjust-placement-of-figure-with-includegraphics
\begin{wrapfigure}[11]{R}{1in - .75\columnsep}
%\centering
\vspace{-\intextsep}
@stanislaw
stanislaw / splitpdf.py
Created July 26, 2020 10:34 — forked from AlexDenisov/splitpdf.py
Splits a PDF file for manual double-side printing
#!/usr/bin/env python3
import sys, os
from PyPDF2 import PdfFileReader, PdfFileWriter
inputname = sys.argv[1]
pdf = PdfFileReader(inputname)
numpages = pdf.getNumPages()
if numpages % 2 == 1:
numpages = numpages - 1