Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

xiaozhuai, Weihang Ding xiaozhuai

🎯
Focusing
  • Shanghai Benqu
View GitHub Profile
@xiaozhuai
xiaozhuai / backtrace.cpp
Created Apr 22, 2021
Android native c++ get back trace (stacktrace)
View backtrace.cpp
#include <tinyformat.h>
#include <unwind.h>
#include <cxxabi.h>
#include <dlfcn.h>
struct android_backtrace_state {
void **current;
void **end;
};
@xiaozhuai
xiaozhuai / pi_alpine_ds3231.md
Last active Jan 21, 2021
Raspberry pi + Alpine + ds3231
View pi_alpine_ds3231.md

Install the RTC module on GPIO pins 1, 3, 5, 7

  1. Add or edit usercfg.txt and add
dtparam=i2c_arm=on
dtoverlay=i2c-rtc,ds3231
  1. Edit /etc/mkinitfs/mkinitfs.conf and add a feature rpirtc, then rebuild initramfs
@xiaozhuai
xiaozhuai / GL_REPEAT-and-GL_MIRRORED_REPEAT-in-shader.md
Last active Jul 21, 2022
Simplely implement GL_REPEAT & GL_MIRRORED_REPEAT in shader
View GL_REPEAT-and-GL_MIRRORED_REPEAT-in-shader.md

OpenGL ES for iOS requires Power-of-Two images, unfortunately, as it is a rather strict implementation.

NPOT textures are technically enabled in the newer iOS hardware running 2.0 ES, but with extremely limited use.

Specifically, you must use linear filtering with clamp-to-edge, and no mipmapping.

And also GL_REPEAT & GL_MIRRORED_REPEAT are not supported.

In most cases a power-of-two image would still be more efficient/have higher framerates.

@xiaozhuai
xiaozhuai / fix_parallels_tools_install.md
Last active Jul 21, 2022
fix parallels tools install issue
View fix_parallels_tools_install.md

install log

cd prl_fs/SharedFolders/Guest/Linux/prl_fs && make CC=cc
make[1]: Entering directory '/usr/lib/parallels-tools/kmods/prl_fs/SharedFolders/Guest/Linux/prl_fs'
make -C /lib/modules/5.0.0-25-generic/build M=/usr/lib/parallels-tools/kmods/prl_fs/SharedFolders/Guest/Linux/prl_fs CC=cc
make[2]: Entering directory '/usr/src/linux-headers-5.0.0-25-generic'
  CC [M]  /usr/lib/parallels-tools/kmods/prl_fs/SharedFolders/Guest/Linux/prl_fs/super.o
/usr/lib/parallels-tools/kmods/prl_fs/SharedFolders/Guest/Linux/prl_fs/super.c: In function 'prlfs_remount':
/usr/lib/parallels-tools/kmods/prl_fs/SharedFolders/Guest/Linux/prl_fs/super.c:119:21: error: 'MS_RDONLY' undeclared (first use in this function); did you mean 'IS_RDONLY'?
  if ( (!((*flags) & MS_RDONLY) && PRLFS_SB(sb)->readonly) ||
@xiaozhuai
xiaozhuai / TAR.bt
Last active Sep 13, 2021
010 editor tar template
View TAR.bt
//--------------------------------------
//--- 010 Editor v6.0.2 Binary Template
//
// File: TAR.bt
// Author: xiaozhuai
// Version: 1.0
// Purpose: Read tar files.
// Category: Archive
// File Mask: *.tar
//--------------------------------------
@xiaozhuai
xiaozhuai / verify_server
Created Apr 23, 2017
jetbrains verify server
View verify_server
http://idea.imsxm.com/
@xiaozhuai
xiaozhuai / angular_filter_bytes.js
Last active Apr 20, 2017 — forked from thomseddon/gist:3511330
AngularJS byte format filter
View angular_filter_bytes.js
app.filter('bytes', function() {
return function(bytes, precision) {
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return '-';
if (typeof precision === 'undefined') precision = 1;
var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'],
number = Math.floor(Math.log(bytes) / Math.log(1024));
return (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision) + ' ' + units[number];
}
});
@xiaozhuai
xiaozhuai / php_post.php
Last active May 12, 2019
php post in 3 ways
View php_post.php
class Request{
public static function post($url, $post_data = '', $timeout = 5){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
if($post_data != ''){
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);