Skip to content

Instantly share code, notes, and snippets.

View ialex32x's full-sized avatar

ialex32x ialex32x

  • Funk Games
  • Shanghai
  • 04:21 (UTC +08:00)
View GitHub Profile
@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"
)
@ialex32x
ialex32x / nonstringkey.js
Created May 9, 2019 03:49
nonstring object as key in javascript
/*
js 总是将key转化为string, 因此不能用像lua那样直接用function等对象作为key
可以利用 Object.defineProperty 来安插 key 来满足近似的需求
*/
var map = {}
var id = 0
function f1() {}
function f2() {}
function addvalue(k, v) {
@ialex32x
ialex32x / keybase.md
Created February 2, 2018 07:09
keybase.md

Keybase proof

I hereby claim:

  • I am ialex32x on github.
  • I am ialex32x (https://keybase.io/ialex32x) on keybase.
  • I have a public key ASApzUZl_G09uCOFvHYhE7xoVCdGMOrT3Ciq02Fw6fu7Wgo

To claim this, I am signing this object:

@ialex32x
ialex32x / get_string_size.m
Created August 28, 2017 08:08
get size of string with font in cocoa touch
NSString *str = ...;
UIFont *font = [UIFont systemFontOfSize:12.0f];
NSDictionary<NSString *, id> *textAttributes = @{NSFontAttributeName: font};
CGRect rect = [str boundingRectWithSize:CGSizeMake(self.bounds.size.width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:textAttributes context:nil];
return rect.size.height;
@ialex32x
ialex32x / nashorn.js
Created July 6, 2017 06:31
Nashorn Basis
# eval
ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
engine.eval("print('hello')");
# javascript
function Person(name) {
this.name = name;
this.getName = function () {
return this.name
}