Skip to content

Instantly share code, notes, and snippets.

View ssrlive's full-sized avatar

ssrlive

  • telegram: realssrlive
  • ssrlivebox(at)gmail(dot)com
View GitHub Profile
@ssrlive
ssrlive / uvcat.c
Last active February 26, 2022 10:09
Best libuv demo with uv_fs_open
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <uv.h>
#if !defined(CONTAINER_OF)
#define CONTAINER_OF(ptr, type, field) \
((type *) ((char *) (ptr) - ((char *) &((type *) 0)->field)))
@ssrlive
ssrlive / vscode.reg
Created March 8, 2022 03:55
VSCode for windows right-click menu in explorer.
Windows Registry Editor Version 5.00
; Open files
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code]
@="Edit with VS Code"
"Icon"="c:\\VSCode\\Code.exe,0"
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code\command]
@="\"c:\\VSCode\\Code.exe\" \"%1\""
@ssrlive
ssrlive / fiber-demo.c
Last active March 24, 2022 07:01
fiber demo in windows.
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
VOID __stdcall ReadFiberFunc(LPVOID lpParameter);
VOID __stdcall WriteFiberFunc(LPVOID lpParameter);
void DisplayFiberInfo(void);
typedef struct {
@ssrlive
ssrlive / list.h
Created March 26, 2022 12:46
list.h header file
#ifndef _LINUX_LIST_H
#define _LINUX_LIST_H
#include <stdio.h>
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
/**
* container_of - cast a member of a structure out to the containing structure
* @ptr: the pointer to the member.
@ssrlive
ssrlive / jmp.c
Created March 26, 2022 12:49
longjmp usage.
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <setjmp.h>
#include <assert.h>
#include <unistd.h>
#include <time.h>
#include "list.h"
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import sys
import http.client
def main(argv):
if len(argv) != 2 :
print("\nUsage: ", argv[0], " <hostname>")
print("\n- <hostname> looks like www.python.org\n")
@ssrlive
ssrlive / connTest.go
Created April 27, 2022 02:40
TCP connectivity test in golang
package main
import (
"fmt"
"net"
"time"
)
func main() {
host := "baidu.com"
/* SPDX-License-Identifier: GPL-2.0
*
* Copyright (C) 2018-2021 WireGuard LLC. All Rights Reserved.
*/
#include <winsock2.h>
#include <Windows.h>
#include <ws2ipdef.h>
#include <iphlpapi.h>
#include <mstcpip.h>
@ssrlive
ssrlive / demo.go
Last active June 24, 2022 12:29
goroutine demo
package main
import (
"fmt"
"io/ioutil"
"time"
)
var query = "test"
var matches int
@ssrlive
ssrlive / quick_sort.c
Created June 30, 2022 07:22
quick sort in C
// quick sort
void swap(int* a, int* b)
{
int tmp = *a;
*a = *b;
*b = tmp;
}
// 快速排序
void quick_sort(int* arr, int left, int right)
{