Skip to content

Instantly share code, notes, and snippets.

@mity
mity / multigrep.sh
Created Mar 26, 2018
Grepping over all git repos found anywhere in the subtree of current working directory.
View multigrep.sh
#!/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
View md-bechmark.sh
#!/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 Jul 18, 2013
Unix file path pattern matching. Not as strong as regular expressions, but sufficient in many cases.
View fpattern.c
/*
* 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 Jul 18, 2013
Simple Windows app skeleton (CreateDialog())
View dlgmain.c
#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 Jul 18, 2013
Simple Windows app skeleton (CreateWindow())
View winmain.c
#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 Jul 18, 2013
RGB <--> HSV color conversion functions for Windows, in integer arithmetics.
View hsv.c
/*
* 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: