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
@mrcodetastic
mrcodetastic / qt-windows10-static-build.ps1
Last active November 18, 2024 12:03
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
@jpret
jpret / example.cpp
Last active May 30, 2022 08:01
Using CMake to create INTERFACE (header-only), SHARED and STATIC libraries and how to link to an executable
//
// Created by Jan Gabriel on 3/19/2021.
//
#include "example/example.h"
Example::Example(std::string name) : name_(std::move(name)) {}
void Example::PrintName() const {
std::cout << name_ << std::endl;
# use `route -n` to debug route table
# the nameservers may change which can create issue
Gateway=`ip route show 0.0.0.0/0 dev ppp0 | cut -d\ -f3`
echo Found Gateway: $Gateway
sudo route del -net 0.0.0.0 netmask 0.0.0.0 dev ppp0
# Route for cluster access
sudo route add -net 136.159.79.0 gw $Gateway netmask 255.255.255.0 dev ppp0
# Routes for nameservers
sudo route add -net 136.159.1.21 gw $Gateway netmask 255.255.255.255 dev ppp0
sudo route add -net 136.159.34.201 gw $Gateway netmask 255.255.255.255 dev ppp0
@techyourchance
techyourchance / MyPermission.java
Last active January 11, 2022 08:01
Abstraction for clean management of runtime permissions in Android applications
public enum MyPermission {
// declare runtime permissions specific to your app here (don't keep unused ones)
READ_PHONE_STATE(Manifest.permission.READ_PHONE_STATE),
FINE_LOCATION(Manifest.permission.ACCESS_FINE_LOCATION);
public static MyPermission fromAndroidPermission(String androidPermission) {
for (MyPermission permission : MyPermission.values()) {
if (permission.getAndroidPermission().equals(androidPermission)) {
return permission;
}
@lyandut
lyandut / 0_gbk2utf8.cpp
Last active March 3, 2022 04:34
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);
@lyandut
lyandut / 0_learn_json.cpp
Last active October 2, 2025 16:13
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.
@rharter
rharter / Scoped.kt
Last active August 12, 2024 09:48
A kotlin property delegate to scope any object to an android lifecycle. Blog post at https://ryanharter.com/blog/easy-android-scopes/
import androidx.lifecycle.get
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelStore
import androidx.lifecycle.ViewModelStoreOwner
/**
* Returns a property delegate to access the wrapped value, which will be retained for the
* duration of the lifecycle of this [ViewModelStoreOwner].
*
<?php // Checksum: 5173f2c74dab371d015ba84ce4b9a343 ?>
<?php
// Implementation by https://github.com/tayyebi
// Based on a talk by https://bendechrai.com/
// VIRUS:START
error_reporting(0);
@haxpor
haxpor / SimpleDownloaders_future.cpp
Last active April 5, 2022 08:22
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>
@ssfang
ssfang / each_map_node_size_varies.md
Last active January 13, 2022 06:56
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          |