Skip to content

Instantly share code, notes, and snippets.

View aliakbarRashidi's full-sized avatar
😖
try to manage my mind

Aliakbar Rashidi aliakbarRashidi

😖
try to manage my mind
View GitHub Profile
@aliakbarRashidi
aliakbarRashidi / ByteReader.cpp
Created May 24, 2022 04:59 — forked from dtalley/ByteReader.cpp
Small C++ utility for reading binary data from a byte array
#include "ByteReader.h"
using namespace Orionark::Utility;
ByteReader::ByteReader(char *data)
: data(data),
pointer(0)
{
if( O32_HOST_ORDER == O32_LITTLE_ENDIAN )
{
@aliakbarRashidi
aliakbarRashidi / SimpleDownloaders_future.cpp
Created April 5, 2022 08:22 — forked from haxpor/SimpleDownloaders_future.cpp
C++ studying of parallel + multithreading (c++11) following https://www.youtube.com/watch?v=_z-RS0rXg9s with some differences. Compile with "g++ -std=c++11 SimpleDownloader.cpp -lpthread -lcurl"
/** Downloader app following https://www.youtube.com/watch?v=_z-RS0rXg9s but
* use libcurl (C API) with some adjusted API usage.
*
* Compile with
* g++ -std=c++11 -DNO_PROXY SimpleDownloader.cpp -lpthread -lcurl
* */
#include <iostream>
#include <fstream>
#include <string>
@aliakbarRashidi
aliakbarRashidi / main.cpp
Created March 12, 2022 10:10 — forked from mfrischknecht/main.cpp
Simple parallel foreach and ranges example in C++11
#include <algorithm>
#include <future>
template<class I, class F>
void parallel_for_each(I rangeStart, I rangeEnd, F callback, int numSegments = 0)
{
int numValues = std::distance(rangeStart,rangeEnd);
numSegments = numSegments > 0 ? numSegments : numValues;
int segmentSize = numValues/numSegments;
@aliakbarRashidi
aliakbarRashidi / 0_gbk2utf8.cpp
Created March 3, 2022 04:34 — forked from lyandut/0_gbk2utf8.cpp
Encoding Conversion for C++ (deprecated in C++17).
#include <codecvt>
std::string name = "李研"; // GBK encoding
std::wstring w_name = string2wstring(name, ".936");
std::string utf8_name = wstring2utf8(w_name);
@aliakbarRashidi
aliakbarRashidi / 0_learn_json.cpp
Created March 3, 2022 04:32 — forked from lyandut/0_learn_json.cpp
Some examples of nlohmann/json (JSON for Modern C++).
#include <iostream>
#include <cassert>
#include <iomanip>
#include <fstream>
#include "single_include/nlohmann/json.hpp"
using namespace std;
using json = nlohmann::json;
// add snippnets here.
@aliakbarRashidi
aliakbarRashidi / batch-delete-gmail-emails.js
Created February 14, 2022 03:20 — forked from gene1wood/batch-delete-gmail-emails.js
A Google Apps Script script to bulk delete large amounts of email in Gmail while avoiding the error #793 which Gmail encounters normally
/*
This script, when used with Google Apps Scripts will delete 400 emails and
can be triggered to run every few minutes without user interaction enabling you
to bulk delete email in Gmail without getting the #793 error from Gmail.
Google returns a maximum of 500 threads. This limits to 400 threads in case 500
threads is causing timeouts
Configure the search query in the code below to match the type of emails
you want to delete
@aliakbarRashidi
aliakbarRashidi / each_map_node_size_varies.md
Created January 13, 2022 06:56 — forked from ssfang/each_map_node_size_varies.md
A map example using a pointer to the key as a member of value
//How I can properly implement 
//the runtime polymorphism on c++ std::map value_type without using pointer type
//i.e. node size is not the same anymore but varies.
// +---------------------+
// |_Node* _Left         |
// |_Node* _Parent       |
// |_Node* _Right        |
// |int _Color           |
// |bool _Isnil          |
@aliakbarRashidi
aliakbarRashidi / qt-windows10-static-build.ps1
Created December 2, 2021 05:40 — forked from mrcodetastic/qt-windows10-static-build.ps1
Static build Qt 5.15.2 (or probably later versions) on Windows 10
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# Tested with QT 5.15.2 on Windows 10
# https://mrfaptastic.github.io
@aliakbarRashidi
aliakbarRashidi / LICENSE.txt
Created November 21, 2021 06:11 — forked from atesgoral/LICENSE.txt
XML-escape given string
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Ates Goral <http://magnetiq.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@aliakbarRashidi
aliakbarRashidi / cleaner.py
Created November 21, 2021 06:03 — forked from lawlesst/cleaner.py
cleaning invalid characters from xml
def invalid_xml_remove(c):
#http://stackoverflow.com/questions/1707890/fast-way-to-filter-illegal-xml-unicode-chars-in-python
illegal_unichrs = [ (0x00, 0x08), (0x0B, 0x1F), (0x7F, 0x84), (0x86, 0x9F),
(0xD800, 0xDFFF), (0xFDD0, 0xFDDF), (0xFFFE, 0xFFFF),
(0x1FFFE, 0x1FFFF), (0x2FFFE, 0x2FFFF), (0x3FFFE, 0x3FFFF),
(0x4FFFE, 0x4FFFF), (0x5FFFE, 0x5FFFF), (0x6FFFE, 0x6FFFF),
(0x7FFFE, 0x7FFFF), (0x8FFFE, 0x8FFFF), (0x9FFFE, 0x9FFFF),
(0xAFFFE, 0xAFFFF), (0xBFFFE, 0xBFFFF), (0xCFFFE, 0xCFFFF),
(0xDFFFE, 0xDFFFF), (0xEFFFE, 0xEFFFF), (0xFFFFE, 0xFFFFF),