Skip to content

Instantly share code, notes, and snippets.

@stanislaw
stanislaw / effective_modern_cmake.md
Created February 11, 2024 21:22 — forked from mbinna/effective_modern_cmake.md
Effective Modern CMake

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

@stanislaw
stanislaw / sch_custom.c
Created July 31, 2023 13:46 — forked from jphickey/sch_custom.c
Simplified "custom" logic for CFS SCH applcation
/*
** $Id: sch_custom.c 1.3 2015/03/01 14:01:44EST sstrege Exp $
**
** Copyright 2007-2014 United States Government as represented by the
** Administrator of the National Aeronautics and Space Administration.
** All Other Rights Reserved.
**
** This software was created at NASA's Goddard Space Flight Center.
** This software is governed by the NASA Open Source Agreement and may be
** used, distributed and modified only pursuant to the terms of that
@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
@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 / 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 / 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 / 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.

#!/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 / 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];
@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,