Skip to content

Instantly share code, notes, and snippets.

@jmbjorndalen
jmbjorndalen / asyncio_executors_threads_procs.py
Created April 26, 2018 08:10
Combining Python 3 asyncio coroutines with thread pool and process pool executors
#!/usr/bin/env python3
# Combining coroutines running in an asyncio event loop with
# blocking tasks in thread pool and process pool executors.
#
# Based on https://pymotw.com/3/asyncio/executors.html, but this version runs both
# threads and processes at the same time and interleaves them with asyncio coroutines.
#
# All appears to be working.
#
@deysumitkr
deysumitkr / ExecutionTime_AlmostGeneric.cpp
Last active November 5, 2019 15:56
Execution time of a code snippet
#include <chrono>
#include <utility>
/**
* @brief find execution time of a function with non-void return type
*
* @tparam F function signature in form return_type(args...). Eg: double(int, int, char*)
* @tparam R set clock resolution from chrono clock (default = std::chrono::microseconds)
* @tparam Args varidac typenames for function arguments
* @param dt execution time as per resolution given in R
@deysumitkr
deysumitkr / getFilesInDir.cpp
Last active March 7, 2023 08:53
get all files in directory - may filter by extension - may recurse - (Boost required)
// usage
std::vector<std::string> exts{".jpg", ".png"};
std::vector<std::string> files = getFilesInDir("/path/to/root/directory/", exts, true);
// --------------------------------------------------------
#define BOOST_FILESYSTEM_NO_DEPRECATED
#include <boost/filesystem.hpp>
@tanaikech
tanaikech / submit.md
Last active July 5, 2024 21:17
Multipart-POST Request Using Google Apps Script

Multipart-POST Request Using Google Apps Script

April 20, 2019: GAS library for this situation was published. Please check it at https://github.com/tanaikech/FetchApp.

These sample scripts are for requesting multipart post using Google Apps Script.

In most cases, the multipart request is used for uploading files. So I prepared 2 sample situations as follows. For each situation, the request parameters are different.

  1. Upload a file from Google Drive to Slack.
  2. Convert an excel file to Spreadsheet on Google Drive using Drive API v3.
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active July 27, 2024 19:57
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@bitjockey42
bitjockey42 / install.md
Created August 7, 2015 19:40
Install SIP and PyQT4 (pyenv, pyenv-virtualenv)

Download

pyenv virtualenv

Switch to the Python version you want to use:

@Tblue
Tblue / mozlz4a.py
Last active July 16, 2024 09:50
MozLz4a compression/decompression utility
#!/usr/bin/env python3
# vim: sw=4 ts=4 et tw=100 cc=+1
#
####################################################################################################
# DESCRIPTION #
####################################################################################################
#
# Decompressor/compressor for files in Mozilla's "mozLz4" format. Firefox uses this file format to
# compress e. g. bookmark backups (*.jsonlz4).
#
@ziogaschr
ziogaschr / debian-wvdial-ppp0-interface-autossh.markdown
Last active July 31, 2023 13:50
Reverse proxy over 3G modem (draft)

Reverse proxy over 3G modem (draft)

We will explain how to configure a cubieboard running debian as a reverese proxy. The modules that will be used are wvdial and autossh

Credits goes to:

1. http://blog.rootshell.be/2015/02/19/my-little-pwnie-box/
2. https://wiki.archlinux.org/index.php/3G_and_GPRS_modems_with_pppd
@Liryna
Liryna / ARMDebianUbuntu.md
Last active May 20, 2024 15:04
Emulating ARM on Debian/Ubuntu

You might want to read this to get an introduction to armel vs armhf.

If the below is too much, you can try Ubuntu-ARMv7-Qemu but note it contains non-free blobs.

Running ARM programs under linux (without starting QEMU VM!)

First, cross-compile user programs with GCC-ARM toolchain. Then install qemu-arm-static so that you can run ARM executables directly on linux

THIS DOCUMENT

IS OUT OF

DATE

C++ Coding Standards Part 0: Automated Code Analysis

Automated analysis is the main advantage to working with a modern statically typed compiled language like C++. Code analysis tools can inform us when we have implemented an operator overload with a non-canonical form, when we should have made a method const, or when the scope of a variable can be reduced.