Skip to content

Instantly share code, notes, and snippets.

--- a/glib/glib/gatomic.c 2012-07-14 17:03:45.000000000 -0500
+++ b/glib/glib/gatomic.c 2013-03-08 14:56:54.644462500 -0600
@@ -464,7 +464,7 @@ gsize
return g_atomic_pointer_xor ((volatile gpointer *) atomic, val);
}
-#elif defined (G_PLATFORM_WIN32)
+#elif defined (G_OS_WIN32)
#include <windows.h>
@nanpuyue
nanpuyue / make-ext4fs_2015-12-02-cygwin.patch
Created January 11, 2016 16:15
make-ext4fs(2015-12-02) pacth for cygwin
diff -ru a/ext4_utils.h b/ext4_utils.h
--- a/ext4_utils.h 2016-01-10 21:05:12.000000000 +0800
+++ b/ext4_utils.h 2016-01-11 23:55:44.369117700 +0800
@@ -38,7 +38,7 @@
#include <setjmp.h>
#include <stdint.h>
-#if defined(__APPLE__) && defined(__MACH__)
+#if (defined(__APPLE__) && defined(__MACH__)) || defined(__CYGWIN__)
#define lseek64 lseek
@nanpuyue
nanpuyue / e2fsprogs_1.42.13-cygwin.patch
Last active January 11, 2016 18:55
e2fsprogs(1.42.13) patch for cygwin
diff -ru a/configure b/configure
--- a/configure 2014-12-01 05:34:31.000000000 +0800
+++ b/configure 2016-01-12 02:51:41.574547800 +0800
@@ -4273,7 +4273,7 @@
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
-if test "$GCC" = yes; then
+if test "$GCC" = yes && test "$host_os" != cygwin; then
RDYNAMIC="-rdynamic"
@nanpuyue
nanpuyue / mtd-utils_1.5.2-cygwin.patch
Created January 12, 2016 13:57
mtd-utils(1.5.2) patch for cygwin
diff -ruN a/include/cygwin/ioctl.h b/include/cygwin/ioctl.h
--- a/include/cygwin/ioctl.h 1970-01-01 08:00:00.000000000 +0800
+++ b/include/cygwin/ioctl.h 2016-01-12 21:54:55.562295400 +0800
@@ -0,0 +1,38 @@
+#ifndef _CYGIOCTL_H_
+#define _CYGIOCTL_H_
+
+#ifdef __CYGWIN__
+
+#define _IOC_NRBITS 8
@nanpuyue
nanpuyue / mklink_for_cygwin_bin.sh
Created January 13, 2016 03:35
mklink for openwrt toolchain bin on cgywin/windows
@nanpuyue
nanpuyue / day.pas
Created March 13, 2014 15:10
输入日期计算星期
program day;
var y,a,b,c,e,f:longint; m,d:word;
begin write('输入日期(年月日,以空格隔开):'); read(y,m,d);
a:=y div 4-y div 100+y div 400;
if (((y mod 4=0) and (y mod 100<>0)) or (y mod 400=0)) and ((m=1) or (m=2)) then b:=1 else b:=0;
c:=y+a+d-b;
case m of
1,10:e:=c+6;
2,3,11:e:=c+2;
4,7,12:e:=c+5;
#!/bin/bash
# author: nanpuyue <nanpuyue@gmail.com> https://blog.nanpuyue.com
# date: 2017-2-28
[[ $(id -u) = 0 ]] || {
echo "Please run this script as root !"
exit -1
}
@nanpuyue
nanpuyue / start_thunder.sh
Last active September 14, 2017 03:33
CrossOver 迅雷极速版启动脚本,用于修复残留窗口遮挡屏幕
#!/bin/bash
# filename: start_thunder.sh
# date: 2017-03-11
# author: nanpuyue <nanpuyue@gmail.com> https://blog.nanpuyue.com
EXIT_TIME=$(( $(date +%s) + 15 ))
exec "/opt/cxoffice/bin/wine" --bottle "迅雷极速版" --check --wait-children --start "C:/users/Public/Start Menu/Programs/迅雷软件/迅雷极速版/启动迅雷极速版.lnk" "$@" &

Keybase proof

I hereby claim:

  • I am nanpuyue on github.
  • I am nanpuyue (https://keybase.io/nanpuyue) on keybase.
  • I have a public key whose fingerprint is 794A 6269 E8A1 8C2E C09C 4454 8EED CF60 4CFE 0321

To claim this, I am signing this object:

@nanpuyue
nanpuyue / format_array.sh
Created March 6, 2018 09:12
格式化输出数组
#!/bin/bash
# date: 2018-03-06
# license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
# author: nanpuyue <nanpuyue@gmail.com> https://blog.nanpuyue.com
P='NONE'
sed -r 's/,/,\n/g;s/\{/\n\{\n/g;s/\}/\n\}/g'|grep -Pv "^\s*$"|\
while read line; do
if [[ "$line" =~ \{ ]];then
[[ "$P" = 'NONE' ]] && P='' || P+='\t'