Skip to content

Instantly share code, notes, and snippets.

View sotex's full-sized avatar
🐢
In human progress and work

风吹过 sotex

🐢
In human progress and work
View GitHub Profile
@sotex
sotex / 修改glibc_version的小程序.c
Last active May 12, 2020 09:02
修改GLIBC_version到低版本,解决version `GLIBC_2.15' not found 问题
/* (c) 2012 Andrei Nigmatulin */
/* Modifiers solym(ymwh@foxmail.com) */
/* 用于去除对 GLIBC 的高版本依赖,将高版本符号替换到低版本 */
#include <elf.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
@sotex
sotex / go并发控制.go
Created May 3, 2020 13:41
Go 并发控制
package main
import "log"
import "time"
import "sync"
var(
ch chan int
wg sync.WaitGroup
)
@sotex
sotex / 自动更新hosts加速github访问.go
Created April 27, 2020 13:38
自动更新hosts加速github访问
/*****************************************************************************
文件: github_hosts_speed.go
描述: 获取 github 相关域名的 ip 地址
作者: solym ymwh@foxmail.com
版本: 2020.04.27
日期: 2020年4月27日
历史:
*****************************************************************************/
package main
@sotex
sotex / singleflight.hpp
Last active January 11, 2024 09:36
singleflight的C++实现版本
// solym
// ymwh@foxmail.com
// 2020年3月16日 20点28分
#include <map>
#include <memory>
#include <mutex>
#include <condition_variable>
@sotex
sotex / C++判断点是否在多边形内.cpp
Created November 12, 2019 07:40
C++判断点是否在多边形内
#include <iostream>
using namespace std;
struct Point {
double m_x;
double m_y;
};
bool pointInPolygon( Point point, Point* vs, int length )
@sotex
sotex / C++验证引用是否指针实现.cpp
Created March 29, 2019 02:05
验证引用是不是使用指针实现的。
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s1 = "Hello World";
string s2 = "你好 美女";
string* ps1 = &s1;
@sotex
sotex / C++一些好用的不在标准库的简单函数.hpp
Last active March 19, 2019 08:45
C++一些不在标准库的方便使用的简单函数
#ifndef __L_Y_M_convenient__
#define __L_Y_M_convenient__
#include <type_traits>
namespace convenient
{
// 限制值范围
template<typename T>
T clamp(T minval, T val, T maxval)
@sotex
sotex / C++11随机数等.cpp
Created February 27, 2019 07:34
C++11随机数等.cpp
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <random>
int main()
@sotex
sotex / 编译期字节序判断.cpp
Created February 27, 2019 07:30
编译期字节序判断.cpp
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
// C++ 11支持强类型枚举和constexpr
enum EndianOrder : uint32_t{
ENDIAN_BIG = 0x00010203, /* 大端序 ABCD */
ENDIAN_LITTLE = 0x03020100, /* 小端序 DCBA */
ENDIAN_BIG_WORD = 0x02030001, /* 中端序 CDAB, Honeywell 316 风格 */
ENDIAN_LITTLE_WORD = 0x01000302 /* 中端序 BADC, PDP-11 风格 */