Skip to content

Instantly share code, notes, and snippets.

View michalfapso's full-sized avatar

Michal Fapso michalfapso

View GitHub Profile
@michalfapso
michalfapso / aa_demo.cpp
Created March 5, 2014 15:20
AntiGrainGeometry demo modified to visualize polygon stitching
#include "agg_basics.h"
#include "agg_rendering_buffer.h"
#include "agg_rasterizer_scanline_aa.h"
#include "agg_scanline_u.h"
#include "agg_renderer_scanline.h"
#include "agg_pixfmt_rgb.h"
#include "platform/agg_platform_support.h"
#include "ctrl/agg_slider_ctrl.h"
#include "ctrl/agg_cbox_ctrl.h"
@michalfapso
michalfapso / aa_demo_agg24.cpp
Last active August 29, 2015 13:57
AntiGrainGeometry demo modified to visualize polygon stitching (AGG 2.4)
#include "agg_basics.h"
#include "agg_rendering_buffer.h"
#include "agg_rasterizer_scanline_aa.h"
#include "agg_scanline_u.h"
#include "agg_renderer_scanline.h"
#include "agg_pixfmt_rgb.h"
#include "platform/agg_platform_support.h"
#include "ctrl/agg_slider_ctrl.h"
#include "ctrl/agg_cbox_ctrl.h"
@michalfapso
michalfapso / aa_float.cpp
Last active August 29, 2015 13:57
AntiGrainGeometry simple float antialiasing
// Compiling:
//
// just put this file into agg24/examples and run:
// g++ -DRECT_X=1 -DRECT_Y=1 -DAGG_GRAY16 -I. -I../include -g -O2 -o aa_float aa_float.cpp
#if !defined(AGG_GRAY8) && !defined(AGG_GRAY16) && !defined(AGG_GRAY32)
#define AGG_GRAY32
#endif
#if defined(AGG_GRAY8)
@michalfapso
michalfapso / emailAddressVerifier.pl
Created May 21, 2012 18:56
emailAddressVerifier.pl: Script for verification of a list of email addresses
#!/usr/bin/perl
use Email::Valid;
use WWW::Mechanize;
use LWP::UserAgent;
#use Thread qw/async yield/;
use threads;
use threads::shared;
@michalfapso
michalfapso / strip_lib.sh
Created March 3, 2016 11:13
Stripping symbols from a static library archive overcoming the error: "strip.exe: cannot create tempdir for archive copying (error: File exists)", when the library contains more than a few object files. The problem is in mktemp("stXXXXXX") which is able to create only 26 unique filenames on the MinGW system "mingw32_4.9.2-posix-sjlj-rt_v3-rev1"
#!/bin/bash
if [ $# -lt 2 ]; then
echo "Usage: $0 LIB_IN LIB_OUT STRIP_PARAMS"
echo "Example: $0 mylib_debug.a mylib_release.a --strip-debug"
fi
LIB_IN="$1"; shift;
LIB_OUT="$1"; shift;
LIB_IN="`realpath "$LIB_IN"`"
@michalfapso
michalfapso / mac_fix_tbd_libraries.sh
Last active February 28, 2018 05:34
After upgrading to XCode 8 and MacOS to 10.12.2, I was getting a linker error when linking with macport's GCC 6: "ld: unexpected token: !tapi-tbd-v2", so this script creates a lybrary symlink for every .tbd file in a given MacOSX SDK path, so that the linker doesn't need the .tbd file at all.
#!/bin/bash
if [ $# -eq 0 ]; then
echo "Usage: $0 MACOSX_SDK_PATH"
echo "Example: $0 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk"
exit 1
fi
for tbd in $(find -L "$1" -name '*.tbd'); do
@michalfapso
michalfapso / main.cpp
Last active May 7, 2020 20:13
How to automatically increase/decrease text size in label in Qt - comment on https://stackoverflow.com/a/42690033/1341914
// standard C++ header:
#include <iostream>
#include <string>
// Qt header:
#include <QApplication>
#include <QBoxLayout>
#include <QFrame>
#include <QGroupBox>
#include <QLabel>

Build instructions:

git clone https://github.com/ReactiveX/RxCpp.git
make
./main

This is the output of the program:

===== println stream of std::string =====

To know which dll libraries need to be bundled with your application, the safest way is to profile your app at runtime, because some libraries may be loaded just at runtime (e.g. Qt plugins). We use MSYS2 (https://www.msys2.org/) for compiling our apps with GCC and MSYS2 contains the strace package which we use here to get a list of loaded dll libraries:

/usr/bin/strace ANY_APP.exe 2>&1 \
| tee out.log \
| grep -a -E '^--- Process .* loaded .*\.dll' \
| cut -d' ' -f 5- \
| sed 's/\.dll.*/.dll/' \
| sort -u
@michalfapso
michalfapso / speak.pl
Last active January 10, 2024 00:52
Google Text-to-Speech script for processing longer texts
#!/usr/bin/perl
#--------------------------------------------------
# Usage:
# ./speak.pl en input.txt output.mp3
#
# Prerequisites:
# sudo apt-get install libwww-perl libhtml-tree-perl sox libsox-fmt-mp3
#
# Compiling sox: