Skip to content

Instantly share code, notes, and snippets.

View josephshen's full-sized avatar

Joseph Shen josephshen

  • Mainland China
View GitHub Profile
@josephshen
josephshen / do-not-copy-vcruntime-by-default.patch
Last active July 17, 2021 15:47
Do Not Copy VC-Runtime by Default
diff --git a/PC/layout/main.py b/PC/layout/main.py
index 3eef755..92fb4ec 100644
--- a/PC/layout/main.py
+++ b/PC/layout/main.py
@@ -178,7 +178,7 @@ def get_layout(ns):
found_any = True
yield dest, src
if not found_any:
- log_error("Failed to locate vcruntime DLL in the build.")
+ log_warning("Failed to locate vcruntime DLL in the build.")
@josephshen
josephshen / restore-support-for-windows-7.patch
Last active October 18, 2023 02:57
Restore Windows7 Support for Python3.9
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index c984e2e..f646498 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -18,7 +18,7 @@
FSCTL_GET_REPARSE_POINT is not exported with WIN32_LEAN_AND_MEAN. */
# include <windows.h>
-# include <pathcch.h>
+# include <Shlwapi.h>
@josephshen
josephshen / prepare_fftw.bat
Last active July 15, 2017 13:53
create fftw lib/include for msvc2015 and msvc2017
@echo off
setlocal
set fftw_32_achive=archive\fftw-3.3.5-dll32.zip
set fftw_64_achive=archive\fftw-3.3.5-dll64.zip
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: percheck and prepare ::
set DEFAULT_PATH=C:\Windows\system32;C:\Windows;
/************************************************************/
/* using template function avoid declare function type twice */
template<typename T>
T load_python_function(void* handle, const char * fun_name)
{
return reinterpret_cast<T>(::dlsym(handle, fun_name));
}
/************************************************************/
/* using template class avoid stupid `(*)` in the type mark */
@josephshen
josephshen / rsync_without_password_input.vbs
Last active November 23, 2016 19:02
rsync over ssh without password
set shell = CreateObject("WScript.Shell")
shell.run"rsync -a Name@192.168.1.100:/Users/Name/Projects/test ."
WScript.Sleep 100
shell.SendKeys"Your_Password"
shell.SendKeys "{ENTER}"
@josephshen
josephshen / detect_msvc_cl_arch.bat
Last active November 23, 2016 19:01
detect cl x64 or x32 mode
where /q cl
if ERRORLEVEL 1 (
echo command msvc cl does not find.
echo make sure msvc cl is installed and placed in path.
exit /B
)
cl 2>&1 | findstr x86 > nul
if ERRORLEVEL 1 (
@josephshen
josephshen / test_mutex_lock.cxx
Created November 14, 2016 05:52
msvc 2015 sp3 std::thread::sleep and std::mutex tricky bug
#include <queue>
#include <unordered_map>
#include <atomic>
#include <mutex>
#include <shared_mutex>
#include <thread>
#include <condition_variable>
#include <iostream>
@josephshen
josephshen / zlib_with_cxx.hxx
Last active May 2, 2016 15:11
zlib with c++
#include <memory>
#include <string>
#include <zlib.h>
std::string inf(const char *source, const size_t length)
{
auto deleter = [](z_stream* strm){ inflateEnd(strm); };
std::unique_ptr<z_stream, decltype(deleter)> \
@josephshen
josephshen / build_openssl_dylib.sh
Created March 26, 2016 16:17 — forked from tmiz/build_openssl_dylib.sh
Build latest OpenSSL Universal Binary on OSX
#!/bin/bash
OPENSSL_VERSION="1.0.1g"
curl -O http://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz
tar -xvzf openssl-$OPENSSL_VERSION.tar.gz
mv openssl-$OPENSSL_VERSION openssl_i386
tar -xvzf openssl-$OPENSSL_VERSION.tar.gz
mv openssl-$OPENSSL_VERSION openssl_x86_64
cd openssl_i386
@josephshen
josephshen / qpaint_draw_xpm.cpp
Last active November 23, 2016 19:02
qpainter draw a mask created using xpm image string
static const char * square_xpm[] = {
"7 7 2 1",
"* c #000000",
". c #ffffff",
"*******",
"*.....*",
"*.....*",
"*.....*",
"*.....*",