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 / Description.html
Last active December 5, 2015 04:53
在 Freenode Web IRC 聊天室中创造瀑布
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta charset="UTF-8" />
</head>
<body>
<p>该脚本提供在 Freenode Web IRC 中多行输入的能力。</p>
<p>请勿用于非法或惹人讨厌的用途!</p>
@xymopen
xymopen / ssprofile.user.js
Last active August 29, 2015 14:20
ShadowX Profile
// ==UserScript==
// @name ShadowX Profile
// @namespace com.gmail.open.xuyiming
// @version 0.2
// @description 在 ShadowX 的节点页面显示 JSON 格式的配置信息
// @author +依然独特
// @match *://shadowx.work/user/node/*
// @match *://shadowx.co/user/node/*
// @include *://shadowx.work/user/node/*
// @include *://shadowx.co/user/node/*
@xymopen
xymopen / Description.html
Last active March 22, 2018 17:47
解除尔雅通识课在自动暂停播放的限制并添加自动播放下一集的功能
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta charset="UTF-8" />
</head>
<body>
<p>该脚本解除尔雅通识课在后台暂停播放和一段时间无操作后暂停播放的限制并添加自动播放下一集的功能。</p>
<br />
@xymopen
xymopen / FakeXHR.js
Last active December 22, 2015 14:24 — forked from ccloli/hook_xhr.js
Netease Music HQ Support (Refactor)
function process( input ) {
console.log( input );
return input;
};
function getPrototypeChain( END_OF_PROTOTYPE_CHAIN ) {
var returns = [ ], currentProto = END_OF_PROTOTYPE_CHAIN;
do {
@xymopen
xymopen / sfx.nsi
Last active June 12, 2016 08:02
A SFX archive script for NSIS
!define SFX_NAME ""
!define SFX_DIR ""
!define SFX_RUN "$INSTDIR\Setup.exe"
!define SFX_ICON ""
!define SFX_OUT ""
VIFileVersion "0.0.0.0"
VIProductVersion "0.0.0.0"
VIAddVersionKey "FileVersion" "0.0.0.0"
@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
@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 / 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 / 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 / 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 ) );
}