Skip to content

Instantly share code, notes, and snippets.

@edwardstock
edwardstock / aes256.cpp
Created Nov 8, 2020
C++ OpenSSL AES256 encryption
View aes256.cpp
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <memory>
#include <stdexcept>
#include <cstring>
#include <openssl/aes.h>
#include <openssl/err.h>
@edwardstock
edwardstock / conan_fallback.cmake
Created Dec 13, 2019
If conan not enabled, trying to find system library of using local subdirectory
View conan_fallback.cmake
function (conan_fallback)
set(options)
set(single NAME LOCAL_INCLUDE_DIR SUBDIR SYSTEM_INCLUDE_DIR TARGET_NAME LOCAL_LIBS_PREFIX)
set(multi PROPERTIES)
cmake_parse_arguments("FF" "${options}" "${single}" "${multi}" ${ARGN})
if (TARGET CONAN_PKG::${FF_NAME})
return()
endif ()
@edwardstock
edwardstock / minter-sdk-java.md
Last active Sep 8, 2020
Minter SDK in pure Java
View minter-sdk-java.md

How to use Minter Android SDK within pure Java/Kotlin project

  1. Download required SDK from official bintray repository: https://bintray.com/minterteam/android

  2. There are 4 files:

    • *-javadoc.jar
    • *-sources.jar
    • *.aar
    • *.pom

    You need *.aar one.

@edwardstock
edwardstock / boost_build.sh
Last active Dec 11, 2018
Boost automated build script
View boost_build.sh
#!/usr/bin/env bash
set -o xtrace
# https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.tar.gz
BOOST_MAJOR_VER="1"
BOOST_MINOR_VER="68"
BOOST_PATCH_VER="0"
BOOST_VER="${BOOST_MAJOR_VER}.${BOOST_MINOR_VER}.${BOOST_PATCH_VER}"
BOOST_VER_US="${BOOST_MAJOR_VER}_${BOOST_MINOR_VER}_${BOOST_PATCH_VER}"
@edwardstock
edwardstock / README.md
Last active Dec 9, 2018
How to create DEB package
View README.md

Step-By-Step guide how to create .deb file from your files

  1. sudo apt-get install devscripts build-essential lintian
  2. Create a directory with prebuild binaries, for example: myproj_1.0.0.orig
  3. myproj_1.0.0.orig must contains a linux file structure, for exampel: binaries should be in myproj_1.0.0.orig/usr/bin, libraries in usr/lib or usr/lib64 et cetera..
  4. Create tar.gz from directory: tar -zcvf myproj_1.0.0.orig.tar.gz myproj_1.0.0.orig
  5. cd myproj_1.0.0.orig
  6. mkdir debian
  7. dch --create -v 1.0.0-1 --package myproj - this command may ask you about preferred editor, select one
  8. Write changelog respecting syntax:
@edwardstock
edwardstock / FFMpegProgress.java
Last active Dec 12, 2020
FFmpeg progress parsing regular expression (with named groups)
View FFMpegProgress.java
public class FFMpegProgress {
// raw
// frame=\s*(?<nframe>[0-9]+)\s+fps=\s*(?<nfps>[0-9\.]+)\s+q=(?<nq>[0-9\.-]+)\s+(L?)\s*size=\s*(?<nsize>[0-9]+)(?<ssize>kB|mB|b)?\s*time=\s*(?<sduration>[0-9\:\.]+)\s*bitrate=\s*(?<nbitrate>[0-9\.]+)(?<sbitrate>bits\/s|mbits\/s|kbits\/s)?.*(dup=(?<ndup>\d+)\s*)?(drop=(?<ndrop>\d+)\s*)?speed=\s*(?<nspeed>[0-9\.]+)x
private final static Pattern PATTERN_S = Pattern.compile("" +
"frame=\\s*(?<nframe>[0-9]+)\\s+" +
"fps=\\s*(?<nfps>[0-9\\.]+)\\s+" +
"q=(?<nq>[0-9\\.-]+)\\s+(L?)\\s*" +
"size=\\s*(?<nsize>[0-9]+)(?<ssize>kB|mB|b)?\\s*" +
"time=\\s*(?<sduration>[0-9\\:\\.]+)\\s*" +
"bitrate=\\s*(?<nbitrate>[0-9\\.]+)(?<sbitrate>bits\\/s|mbits\\/s|kbits\\/s)?.*" +
@edwardstock
edwardstock / gradle.properties
Created Sep 17, 2018
Gradle optimized properties
View gradle.properties
org.gradle.jvmargs=-Xmx15g -Xms1g -XX:MaxPermSize=2g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
org.gradle.configureondemand=true
org.gradle.daemon=true
org.gradle.workers.max=8
org.gradle.caching=true
@edwardstock
edwardstock / git_fix_permissions.sh
Created Sep 13, 2018
GIT revert file mode changes
View git_fix_permissions.sh
#!/usr/bin/env bash
cd $1
git diff -p -R --no-color | grep -E "^(diff|(old|new) mode)" --color=never | git apply
## add git alias with name "permission-reset"
git config --global --add alias.permission-reset '!git diff -p -R --no-color | grep -E "^(diff|(old|new) mode)" --color=never | git apply'
@edwardstock
edwardstock / DecimalInputFilter.java
Created Aug 31, 2018
Android Decimal Number Input Filter
View DecimalInputFilter.java
public class DecimalInputFilter extends android.text.method.DigitsKeyListener {
private final WeakReference<EditText> mView;
private int mDecimals = 18;
public DecimalInputFilter(EditText txtView) {
this(txtView, 18);
}
public DecimalInputFilter(EditText txtView, int decimals) {
super(false, true);
@edwardstock
edwardstock / Build-GCC-README.md
Last active Mar 1, 2019
GNU GCC 8.1 automated build script
View Build-GCC-README.md