Skip to content

Instantly share code, notes, and snippets.

@mity
mity / multigrep.sh
Created March 26, 2018 11:29
Grepping over all git repos found anywhere in the subtree of current working directory.
#!/bin/bash
#
# Grepping over all git repos found anywhere in the subtree of current working
# directory.
#
find . -type d -name .git | while read line; do
repo=`dirname "$line"`
( cd "$repo" && git grep -n "$@" | sed "s|^|$repo/|" )
done
#!/bin/bash
# Generate samples to examine some basic features of the parser:
rm -rf samples
mkdir samples
touch samples/empty.md
#cp ~/prj/cmark/bench/benchinput.md samples/cmark-benchinput.md
#python3 -c 'print("\n" * 10*1000000)' > samples/many-blanks.md
@mity
mity / fpattern.c
Created July 18, 2013 23:58
Unix file path pattern matching. Not as strong as regular expressions, but sufficient in many cases.
/*
* Unix file path pattern-based matching.
* Copyright (c) 2013 Martin Mitas
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
@mity
mity / dlgmain.c
Created July 18, 2013 23:46
Simple Windows app skeleton (CreateDialog())
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
/* To use this, you have to create rsource script to accompany this file,
* providing the dialog resource with this resource ID. */
#ifndef IDD_MAIN
#define IDD_MAIN 1000
@mity
mity / winmain.c
Created July 18, 2013 23:45
Simple Windows app skeleton (CreateWindow())
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
static LRESULT CALLBACK
win_proc(HWND win, UINT msg, WPARAM wp, LPARAM lp)
{
switch(msg) {
@mity
mity / hsv.c
Created July 18, 2013 23:38
RGB <--> HSV color conversion functions for Windows, in integer arithmetics.
/*
* RGB <--> HSV conversion in integer arithmetics, to be used on Windows.
* Copyright (c) 2013 Martin Mitas
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions: