Skip to content

Instantly share code, notes, and snippets.

View leeyisoft's full-sized avatar
🏠
Working from home

leeyi leeyisoft

🏠
Working from home
View GitHub Profile
@y0ngb1n
y0ngb1n / docker-registry-mirrors.md
Last active June 24, 2024 07:40
国内的 Docker Hub 镜像加速器,由国内教育机构与各大云服务商提供的镜像加速服务 | Dockerized 实践 https://github.com/y0ngb1n/dockerized
@ArthurClemens
ArthurClemens / multipart-upload.erl
Created September 17, 2016 12:07
Erlang: upload data using multipart/form-data
%% Usage:
%% upload_request(<<"site.com/api/upload">>, <<"path/to/file.png">>, <<"upload">>, <<"image/png">>, [], <<"some-token">>)
%%
%% Usage with RequestData:
%% Payload = [{upload_type, <<"user_picture">>}],
%% PayloadContent = jsx:encode(Payload),
%% RequestData = [
%% {<<"payload">>, PayloadContent}
%% ]
%% upload_request(<<"site.com/api/upload">>, <<"path/to/file.png">>, <<"upload">>, <<"image/png">>, RequestData, <<"some-token">>)
@li-jkwok
li-jkwok / gist:e460a042326e8509ada9ec23ae677bdf
Created August 1, 2016 18:39
Getting Total Disk Space Available for Android Device
/**
* Get the total disk space available on this Android Device
*
* @return total size (in bytes) that is the total disk space avaialble on the device.
*/
public static long getTotalDiskSpace() {
StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath());
long totalDiskSpace = statFs.getBlockCount() * statFs.getBlockSize();
return totalDiskSpace;
}
@zhongwencool
zhongwencool / timing_wheel.erl
Created June 26, 2014 06:54
一个简单的分层时间轮实现:类似于3维数组实现时钟
%%%-------------------------------------------------------------------
%%% @author zhongwencool@gmail.com
%%% @doc 一个简单的分层时间轮实现:类似于3维数组实现时钟
%%% 根据 http://www.embeddedlinux.org.cn/RTConforEmbSys/5107final/LiB0071.html 实现
%%% 1.时钟原理说明:
%%% 1.1. 初始化一个三层时间轮:秒刻盘:0~59个SecList, 分刻盘:0~59个MinList, 时刻盘:0~12个HourList;
%%% 1.2. SecTick由外界推动,每跳一轮(60格),SecTick复位至0,同时MinTick跳1格;
%%% 1.3. 同理MinTick每跳一轮(60格),MinTick复位至0,同时HourTick跳1格;
%%% 1.4. 最高层:HourTick跳一轮(12格),HourTick复位至0,一个时间轮完整周期完成.
%%% 2.事件原理说明:
@yongboy
yongboy / client5.c
Last active June 6, 2020 22:14
just add http header attribute
#include <sys/types.h>
#include <sys/time.h>
#include <sys/queue.h>
#include <stdlib.h>
#include <err.h>
#include <event.h>
#include <evhttp.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>