Skip to content

Instantly share code, notes, and snippets.

View jj11hh's full-sized avatar

Jiang Yiheng jj11hh

  • Netease Games
  • Zhejiang, China
View GitHub Profile
@jj11hh
jj11hh / AndroidReadAsset.cs
Created June 28, 2024 06:18
A test script to read apk assets with JNI.
using System;
using System.Runtime.InteropServices;
using System.Text;
using UnityEngine;
public class AndroidReadAsset : MonoBehaviour
{
#if UNITY_ANDROID && !UNITY_EDITOR
[DllImport("libc")]
@jj11hh
jj11hh / csv2obj.py
Created May 29, 2024 03:28
A script to convert CSV dump from Renderdoc into OBJ mesh format.
from argparse import ArgumentParser
def main():
parser = ArgumentParser(description="Script to convert CSV to OBJ file")
parser.add_argument("input", type=str, help="Input CSV file path")
parser.add_argument("output", type=str, help="Output OBJ file path")
parser.add_argument("--flip-y", action="store_true", help="Flip Y")
parser.add_argument("--flip-uv", action="store_true", help="Flip UV")
@jj11hh
jj11hh / Knob.vue
Created October 2, 2020 07:46
Knob component for Vue framework
<template>
<div
class="container"
v-bind:style="containerStyle"
v-on:mousedown="mousedown"
v-on:mousemove="mousemove"
v-on:wheel="handleWheel"
>
<div class="handle" v-bind:style="handleStyle"></div>
</div>
@jj11hh
jj11hh / loopbuf.h
Last active February 4, 2021 11:02
#ifndef __LOOPBUF_H__
#define __LOOPBUF_H__
#define LOOPBUF_DEFINE(type, capacity, varname) \
struct { \
unsigned char in; \
unsigned char out; \
type buf[ capacity ]; \
} varname;
@jj11hh
jj11hh / streamsummary.h
Last active June 26, 2020 08:35
StreamSummary data structure for Space Saving algorithm
#ifndef STREAMSUMMARY_H
#define STREAMSUMMARY_H
#include <list>
#include <unordered_map>
#include <vector>
#include <tuple>
#include <string>
#include <algorithm>
#include <cstdlib>
@jj11hh
jj11hh / twoSum.c
Created May 22, 2020 15:51
hash table and fast two sum in C
typedef struct _node {
int k;
int v;
struct _node * next;
} node;
static int hash (int x, int m){
return ((x ^ 0x3FB15C87) & ~0x80000000) % m;
}
@jj11hh
jj11hh / async_dec2hex.js
Last active May 19, 2020 11:28
convert decimal numbers to hexadecimal asynchoronously
function xxx_rpc_call(x, callback){
setTimeout(callback, 1000 + Math.random()*1000, x.toString(16));
}
const results = new Array();
let index = 1;
function cb_arrange(x){
return (result) => {
results[x] = result;
if (x == 1 || results[x - 1] !== undefined){
@jj11hh
jj11hh / system-backup
Created May 17, 2020 15:06
backup ubuntu system to another partition
#!/bin/bash
cd / # THIS CD IS IMPORTANT THE FOLLOWING LONG COMMAND IS RUN FROM /
mount /dev/nvme0n1p9 /mnt || exit 1
tar -cvpzf /mnt/backup-$(date +%F_%H%M%S).tar.gz \
--exclude=/proc \
--exclude=/tmp \
--exclude=/mnt \
--exclude=/dev \
--exclude=/sys \
@jj11hh
jj11hh / rules.v4
Created May 14, 2020 05:26
Transparent proxy with v2ray
# Generated by xtables-save v1.8.2 on Mon Feb 24 19:24:15 2020
*mangle
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
:V2RAY - [0:0]
:V2RAY_MASK - [0:0]
-A PREROUTING -j V2RAY
@jj11hh
jj11hh / gist:ad9006f1da61fed26653565ca9bb4852
Created May 9, 2020 16:04
remove all configure files of removed packages on Ubuntu
sudo dpkg --purge $(dpkg --get-selections | grep deinstall | cut -f1)