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
@leeyisoft
leeyisoft / multipart-upload.erl
Created May 31, 2023 10:19 — forked from ArthurClemens/multipart-upload.erl
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">>)
@leeyisoft
leeyisoft / gist:9037c64d3ff97a851a17eae2c90c9c8d
Created November 25, 2022 10:50
Perfect negotiation with Flutter-WebRTC
import 'package:flutter_webrtc/flutter_webrtc.dart';
import 'package:vpl_frontend/calls/ws_messages.dart';
import 'package:vpl_frontend/utils/api.dart';
import 'call_manager_base.dart';
class RtcConnection {
MediaStream _localStream;
RTCPeerConnection _peerConnection;
RTCVideoRenderer _localRenderer = RTCVideoRenderer();
@leeyisoft
leeyisoft / dt_util.erl
Last active July 14, 2020 10:02
阿里云短信服务短信发送API(SendSms) Erlang版本
-module (dt_util).
%%%
% datetime 工具箱
%%%
-export ([milliseconds/0]).
-export ([utc_date/1]).
%% 得到现在在制时间毫秒
milliseconds() ->
@leeyisoft
leeyisoft / timing_wheel.erl
Created June 10, 2020 11:36 — forked from zhongwencool/timing_wheel.erl
一个简单的分层时间轮实现:类似于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.事件原理说明:
@leeyisoft
leeyisoft / client5.c
Created June 6, 2020 22:13 — forked from yongboy/client5.c
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>
@leeyisoft
leeyisoft / DigestUtils.java
Last active March 25, 2021 10:22
支持SHA-1/MD5消息摘要的工具类. Java 版本 和对应的PHP版本 和对应Python3版本 (在JDK 1.8.0_51 和 PHP 7.1.11 和 Python 3.6.0 测试ok);添加 pbkdf2_sha256 加密解密功能(在JAVA和Python对接成功)
/**
* Copyright (c) 2005-2012 springside.org.cn
*/
package com.rd.ifaes.common.util;
import com.rd.ifaes.common.exception.BussinessException;
import org.apache.commons.lang3.Validate;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
@leeyisoft
leeyisoft / wxpy_bot.py
Created August 31, 2017 08:16
pip3 install -U wxpy \n mkdir pkl
#!/usr/bin/env python3
# encoding: utf-8
import requests
import base64
import hashlib
import os
from wxpy import *
from wxpy.api.chats.friend import Friend
@leeyisoft
leeyisoft / qqbot-tmp_v2.3.conf
Last active August 23, 2017 06:49
qqbot 登陆二维码发送到指定服务的插件
{
# QQBot 的配置文件
# 使用 qqbot -u somebody 启动程序时,依次加载:
# 根配置 -> 默认配置 -> 用户 somebody 的配置 -> 命令行参数配置
# 使用 qqbot 启动程序时,依次加载:
# 根配置 -> 默认配置 -> 命令行参数配置
# 用户 somebody 的配置
"8187" : {
# QQBot-term (HTTP-API) 服务器端口号(该服务器监听 IP 为 127.0.0.1 )
@leeyisoft
leeyisoft / RpcClient
Last active August 31, 2017 08:18
php rpc client (rabbitmq)
<?php
/**
* @desc Advanced Message Queuing Protocol RPC Client
*
* @name RpcClient
* @copyright leeyi.net @ 2014-2020
* @author leeyi <leeyisoft@icloud.com>
*/
namespace app\lib\AMQP;
@leeyisoft
leeyisoft / Pusher.php
Last active August 23, 2017 01:30
PHP rabbitmq producer for yii2
<?php
/**
* Advanced Message Queuing Protocol 发送消息类
*
* @copyright leeyi.net @ 2014-2020
* @author leeyi <leeyisoft@icloud.com>
*/
namespace app\lib\AMQP;