Skip to content

Instantly share code, notes, and snippets.

View Mattosx's full-sized avatar

mattos Mattosx

  • Netease
  • Hangzhou
View GitHub Profile
@Mattosx
Mattosx / rbtree.c
Created July 1, 2016 14:16 — forked from hoohack/rbtree.c
Red Black Implement
#include "rbtree.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
RBTree *rbtree_init(int (*rbt_keycmp)(void *, void *))
{
RBTree *tree = malloc(sizeof(RBTree));
if (tree == NULL) {
printf("malloc tree failed\n");
string replaceNullStr(const char* input){
size_t srcLen = strlen(input);
const char* p = input;
int nullStr = 0;
while (*p != '\0') {
if (*p == ' ') {
++nullStr;
}
++p;
}
int bytes2string(unsigned char *src, int srcsize, unsigned char *dst, int dstsize)
{
if (dst != NULL)
{
*dst = 0;
}
if (src == NULL || srcsize <= 0 || dst == NULL || dstsize <= srcsize * 2)
{
return 0;
@Mattosx
Mattosx / tfo.c
Created September 13, 2018 09:31 — forked from linusyang/tfo.c
// x86_64-w64-mingw32-gcc tfo.c -o tfo -lws2_32 -static -g -O0
#define TARGET_URL "localhost"
#define TARGET_PORT 8000
#ifndef _WINSOCK_H
#define _WINSOCK_H
#ifdef __MINGW32__
@Mattosx
Mattosx / eventsim.py
Created September 17, 2018 07:13 — forked from damonjw/LICENSE
Event driven simulator in Python, using async/await
import heapq
import asyncio
class EventSimulator(asyncio.AbstractEventLoop):
'''A simple event-driven simulator, using async/await'''
def __init__(self):
self._time = 0
self._running = False
self._immediate = []
@Mattosx
Mattosx / gist:1b835342cd8a0d8c55f4ecef239902b1
Created November 26, 2018 07:41
process communication via mmap
/*************************************************************************\
* Copyright (C) Michael Kerrisk, 2016. *
* *
* This program is free software. You may use, modify, and redistribute it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation, either version 3 or (at your option) any *
* later version. This program is distributed without any warranty. See *
* the file COPYING.gpl-v3 for details. *
\*************************************************************************/
@Mattosx
Mattosx / .gitignore
Created March 8, 2019 11:13 — forked from FullStackForger/.gitignore
.gitignore for Unity3d project
###
# Unity folders and files
###
[Aa]ssets/AssetStoreTools*
[Bb]uild/
[Ll]ibrary/
[Ll]ocal[Cc]ache/
[Oo]bj/
[Tt]emp/
[Uu]nityGenerated/
isolation.tools.getPtrLocation.disable = "TRUE"
isolation.tools.setPtrLocation.disable = "TRUE"
isolation.tools.setVersion.disable = "TRUE"
isolation.tools.getVersion.disable = "TRUE"
monitor_control.disable_directexec = "TRUE"
monitor_control.disable_chksimd = "TRUE"
monitor_control.disable_ntreloc = "TRUE"
monitor_control.disable_selfmod = "TRUE"
monitor_control.disable_reloc = "TRUE"
monitor_control.disable_btinout = "TRUE"
# EXAMPLE OUTPUT
# ==============
# opening device 0xddcc
# connected
# tester present ...
# read data by id: boot software id ...
# 39990-TVA-A110
# read data by id: application software id ...
# 39990-TVA-A150
# read data by id: application data id ...
@Mattosx
Mattosx / nmap-scan-show-open.sh
Created January 24, 2021 12:20 — forked from gregjhogan/nmap-scan-show-open.sh
nmap scan for port open and only show open results
nmap -p <port> 192.168.0.*|grep -B3 open