Skip to content

Instantly share code, notes, and snippets.

View xymopen's full-sized avatar

xymopen_Official xymopen

  • Shanghai, China
View GitHub Profile
@xymopen
xymopen / openid-configuration.json
Created October 13, 2023 16:29
GitHub OAuth App OIDC Configuration
{
"issuer": "https://github.com",
"authorization_endpoint": "https://github.com/login/oauth/authorize",
"token_endpoint": "https://github.com/login/oauth/access_token",
"userinfo_endpoint": "https://api.github.com/user",
"scopes_supported": [
"repo",
"repo:status",
"repo_deployment",
"public_repo",
@xymopen
xymopen / git-mingw.cmd
Last active December 16, 2020 14:19
Start a cmd with MinGW come with Git for Windows
@echo off
setlocal
for /f "delims=" %%i in ('where git') do (
set "GIT_PATH=%%~dpi"
goto _end_of_where
)
:_end_of_where
@xymopen
xymopen / open-terminals.md
Last active May 15, 2024 10:43 — forked from auroursa/open-windows-terminal-in-current-folder.md
Open Windows Terminal and Fluent Terminal in current folder

Open Windows Terminal and Fluent Terminal in current folder

Using Registry to add "Terminal Here" in the context menu.

Icon value is optional, path may change with different version.

notice change [your username] to the correct username.

Use cmd.exe to resolve executable from %PATH%. Require that %UserProfile%\AppData\Local\Microsoft\WindowsApps is presented at %PATH% of system environment variable (which is default).

@xymopen
xymopen / fernflower.ps1
Last active April 23, 2022 01:03
IntelliJ IDEA Java decompiler wrapper script for PowerShell
############################################################################
#
# IntelliJ IDEA Java Decompiler wrapper script for Windows
#
# @see https://stackoverflow.com/questions/28389006/how-to-decompile-to-java-files-intellij-idea/30106981
# @see https://github.com/JetBrains/intellij-community/tree/master/plugins/java-decompiler/engine
#
############################################################################
$IDEA_PATH = "$Env:ProgramFiles\JetBrains\IntelliJ IDEA 2020.1.1"
@echo off
setlocal EnableExtensions
setlocal EnableDelayedExpansion
set STUDENT_MAIN_PATH="C:\Program Files\Mythware\e-Learning Class\StudentMain.exe"
set LOCAL_INTERFACE="本地连接"
set FIREWALL_RULE_NAME_1="Block Mythware e-Learning class(UDP 4605)"
set FIREWALL_RULE_NAME_2="Block Mythware e-Learning class(StudentMain.exe)"
@xymopen
xymopen / linux_magic.cpp
Created October 17, 2017 14:00
C++ equivalences of the famous offset_of and container_of(owner_of) macro from Linux kernel
template< class T, class M >
static inline constexpr ptrdiff_t offset_of( const M T::*member ) {
return reinterpret_cast< ptrdiff_t >( &( reinterpret_cast< T* >( 0 )->*member ) );
}
template< class T, class M >
static inline constexpr T* owner_of( M *ptr, const M T::*member ) {
return reinterpret_cast< T* >( reinterpret_cast< intptr_t >( ptr ) - offset_of( member ) );
}
@xymopen
xymopen / reverseByte.c
Last active October 9, 2017 15:10
Code snippet to reverse a byte from StackOverflow
// https://stackoverflow.com/questions/2602823/in-c-c-whats-the-simplest-way-to-reverse-the-order-of-bits-in-a-byte
unsigned char rvs_byte( unsigned char b ) {
b = ( b & 0b11110000 ) >> 4 | ( b & 0b00001111 ) << 4;
b = ( b & 0b11001100 ) >> 2 | ( b & 0b00110011 ) << 2;
b = ( b & 0b10101010 ) >> 1 | ( b & 0b01010101 ) << 1;
return b;
};
@xymopen
xymopen / wifi_switch.sh
Last active February 28, 2019 10:42
Automatically switch on or off Wi-Fi according to an interface. Helpful if your mobile phone won't switch to mobile data if there is no internet access from Wi-Fi.
#!/bin/sh
# wifi_switch.sh
# hotplug.d script
# Automatically switch on or off wifi according to an interface
# helpful if your mobile phone won't switch to mobile data if there is no internet access from wifi
# Version : 2.2.0
# Author : xymopen <xuyiming.open@outlook.com>
# Licensed : BSD 2-clause License
@xymopen
xymopen / electron-npm.cmd
Last active March 9, 2017 06:28
Set up environment variables for npm to deploy packages for electron.
@echo off
call electron.cmd --version 1>NUL 2>&1
if ERRORLEVEL 1 echo Cannot access Electron executable && goto END
:: Electron's version.
for /f %%i in ( 'call electron.cmd --version' ) do set _tmp=%%i
set npm_config_target=%_tmp:v=%
echo npm_config_target=%npm_config_target%
@xymopen
xymopen / waifu2x.bat
Last active February 17, 2017 20:19
a Windows CMD batch to process images with https://github.com/tanakamura/waifu2x-converter-cpp.
@echo off
pushd "%~dp0"
setlocal enabledelayedexpansion
if /i %PROCESSOR_ARCHITECTURE% == x86 set bin=waifu2x-converter_x86.exe
if /i %PROCESSOR_ARCHITECTURE% == amd64 set bin=waifu2x-converter_x64.exe
:LOOP
set __test=%1