Skip to content

Instantly share code, notes, and snippets.

View lyf-is-coding's full-sized avatar
💓
Live Laugh Love

lyf-is-coding

💓
Live Laugh Love
View GitHub Profile
@lyf-is-coding
lyf-is-coding / uppercase_lowercase_str.cpp
Created February 23, 2022 15:54
C++ STL Uppercase/ Lowercase string
// Input : abHDbGd
// Output : ABHDBGD - abhdbgd
#include <string>
std::string UppercaseStr(std::string str)
{
int str_length = str.length();
for (int i = 0; i < str_length; ++i)
@lyf-is-coding
lyf-is-coding / get_admin.cmd
Created March 11, 2022 12:04
Windows CMD file get Administrative privileges
@echo off
:: BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
IF '%errorlevel%' NEQ '0' (
ECHO Requesting administrative privileges...
GOTO UACPrompt
@lyf-is-coding
lyf-is-coding / recoil_reducer.ahk
Created March 31, 2022 11:58
AHK recoil reducer
#NoEnv
SendMode Input
Insert:: Hotkey, *~$LButton, Toggle
*~$LButton::
while GetKeyState("LButton")
{
DllCall("mouse_event", uint, 1, int, 0, int, 1, uint, 0, int, 0)
Sleep, 15
@lyf-is-coding
lyf-is-coding / chromium_specific_tag_source_code.txt
Created June 7, 2022 12:27
Chromium get and compile source code with specific tag
Step 1: Follow the instruction from google
https://chromium.googlesource.com/chromium/src/+/main/docs/windows_build_instructions.md
Step 2: git fetch --tags
Step 3: git checkout tags/<version>
Example: git checkout tags/102.0.5005.53
Step 4: gclient sync -D
@lyf-is-coding
lyf-is-coding / android-backup-apk-and-datas.md
Created June 9, 2022 01:39 — forked from AnatomicJC/android-backup-apk-and-datas.md
Backup android app, data included, no root needed, with adb

Backup android app, data included, no root needed, with adb

adb is the Android CLI tool with which you can interact with your android device, from your PC

You must enable developer mode (tap 7 times on the build version in parameters) and install adb on your PC.

Don't hesitate to read comments, there is useful tips, thanks guys for this !

Fetch application APK

@lyf-is-coding
lyf-is-coding / android-adb-pull-apk.md
Created June 23, 2022 01:46 — forked from ctrl-freak/android-adb-pull-apk.md
Retrieve APK from Non-Rooted Android Device through ADB

https://stackoverflow.com/a/18003462/348146

None of these suggestions worked for me, because Android was appending a sequence number to the package name to produce the final APK file name (this may vary with the version of Android OS). The following sequence of commands is what worked for me on a non-rooted device:

  1. Determine the package name of the app, e.g. com.example.someapp. Skip this step if you already know the package name.

    adb shell pm list packages

    Look through the list of package names and try to find a match between the app in question and the package name. This is usually easy, but note that the package name can be completely unrelated to the app name. If you can't recognize the app from the list of package names, try finding the app in Google Play using a browser. The URL for an app in Google Play contains the package name.

@lyf-is-coding
lyf-is-coding / find__RequestVerificationToken.py
Created June 26, 2022 14:12
Python find __RequestVerificationToken
# Make a request to the website to get the html file
# Parse the html file and find the __RequestVerificationToken then use it to make other requests :)
# __RequestVerificationToken always stay in input tag
# example:
# <input name="__RequestVerificationToken" type="hidden" value="cm486PKVb3TS04HQEjXhoYcwjQxTXgPfdJLnqOJ8NOqXWlJ_hwjdCEYmPxfLYbkRudBFctFKcXchfTHSgPlRq4xMGmGcIZqZivduIxmvsDs1">
# read more about __RequestVerificationToken
# https://blog.stevensanderson.com/2008/09/01/prevent-cross-site-request-forgery-csrf-using-aspnet-mvcs-antiforgerytoken-helper/
@lyf-is-coding
lyf-is-coding / convert_timestamp.py
Last active June 28, 2022 11:00
Python convert timestamp to date time
from datetime import datetime
def timestamp_to_datetime(timestamp : float, format : str):
try:
date = datetime.fromtimestamp(timestamp).strftime(format)
return date
except:
timestamp /= 1000
date = datetime.fromtimestamp(timestamp).strftime(format)
return date
@lyf-is-coding
lyf-is-coding / Hide special variables and function variables.json
Last active June 28, 2022 11:13
VSCode Python debug: Hide special variables and function variables
// Ctrl + Shift + P: Open launch.json
// Then add these 3 lines under configurations
"variablePresentation": {
"function": "hide",
"special": "hide",
}
@lyf-is-coding
lyf-is-coding / imgui_drag_and_drop.cpp
Last active July 9, 2022 14:58
C++ ImGui Drag and drop item inside collapsing header
if (ImGui::CollapsingHeader(group.name.c_str()))
{
float window_width = ImGui::GetWindowPos().x + ImGui::GetWindowContentRegionMax().x;
size_t buttonCounts = group.apps.size();
for (int index = 0; index < buttonCounts; ++index)
{
ImGui::PushID(index);
ImGui::Button(group.apps[index].name.c_str(), button_sz);