Skip to content

Instantly share code, notes, and snippets.

View ialex32x's full-sized avatar

ialex32x ialex32x

  • Funk Games
  • Shanghai
  • 04:08 (UTC +08:00)
View GitHub Profile
#include <iostream>
#include <string>
#define MAKE_FUNC_BODY(...) static __VA_ARGS__ { __assume(false); }
#define MAKE_TYPE_CONSTRAINT(Name, ...) struct Name { MAKE_FUNC_BODY(__VA_ARGS__) };
template<typename T>
int call(int index, T const& v) { std::cout << "-["<<index<<"] " << v << std::endl; return index+1; }
int call(int index, std::string const& v) { std::cout << "+["<<index<<"] " << v << std::endl; return 100; }
@ialex32x
ialex32x / v8-test.cpp
Created March 27, 2025 00:47
v8-test
#include <atomic>
#include <iostream>
#include <cassert>
#include <map>
#include <unordered_map>
#include <libplatform/libplatform.h>
#include <cppgc/allocation.h>
#include <cppgc/garbage-collected.h>
@ialex32x
ialex32x / godot_prop_def_filepath_array.cpp
Created February 13, 2025 02:19
How to define a PropertyInfo for filepath array
PropertyInfo PackagingIncludeFiles;
PackagingIncludeFiles.type = Variant::ARRAY;
PackagingIncludeFiles.name = "MyPropertyName";
PackagingIncludeFiles.hint = PROPERTY_HINT_ARRAY_TYPE;
PackagingIncludeFiles.hint_string = vformat("%s/%s:%s", Variant::STRING, PROPERTY_HINT_FILE, "*.abc,*.xyz");
@ialex32x
ialex32x / jsc_hello_world.cpp
Last active January 25, 2025 02:20
jsc hello world from scratch
#include <iterator>
#include <cstdint>
#include <thread>
#include <JavaScriptCore/JavaScriptCore.h>
JSValueRef ObjectCallAsFunctionCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) {
char buf[1024];
for (int i = 0; i < argumentCount; ++i) {
JSValueRef val = arguments[i];
if (JSStringRef str = JSValueToStringCopy(ctx, val, nullptr)) {
@ialex32x
ialex32x / vue_parsetext.ts
Created June 15, 2021 05:30
'parseText' in Vue.js
var validDivisionCharRE = /[\w).+\-_$\]]/;
function parseFilters(exp) {
var inSingle = false;
var inDouble = false;
var inTemplateString = false;
var inRegex = false;
var curly = 0;
var square = 0;
@ialex32x
ialex32x / timingwheel.cs
Last active July 24, 2019 03:03
simple timingwheel in csharp
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApp1
{
internal class TimeHandle
{
public uint id;
public Action<uint> action;
@ialex32x
ialex32x / kill_and_run.bat
Created May 13, 2019 09:01
在 bat 批处理中杀死和启动进程
SET EXE=.\bin\sgless
REM 杀掉所有指定进程名的进程
taskkill /f /im %EXE%
REM 杀掉所有指定窗口名字和进程名的进程
taskkill /f /im %EXE% /fi "WINDOWTITLE eq NT_CENTER"
@ialex32x
ialex32x / kill.sh
Created May 13, 2019 08:57
sh 查找所有指定名字的进程并杀死
#!/bin/bash
WORKSPACE=$(cd `dirname $0`;pwd)
EXE=./bin/sgless
LOGPATH=./log
echo killing old
ps aux | grep $EXE | awk '{print $2}' | xargs kill -9
sleep 1s
@ialex32x
ialex32x / check_last_error.bat
Created May 13, 2019 08:48
在bat批处理中判断上一条命令执行结果
echo building...
go build -o sgless
if %errorlevel% NEQ 0 (
exit 2
)
echo all done!
@ialex32x
ialex32x / interface_addrs.go
Last active May 13, 2019 02:21
how to iterate net interfaces in golang
/*
go 获取所有网卡地址
*/
package main
import (
"fmt"
"net"
)