Skip to content

Instantly share code, notes, and snippets.

Malcolm Ke Win diyism

Block or report user

Report or block diyism

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@diyism
diyism / udp traffic forwording with swoole udp server or swoole udp client.php
Created Jan 7, 2020
udp traffic forwording with swoole udp server or swoole udp client
View udp traffic forwording with swoole udp server or swoole udp client.php
<?php
$ch='';
$udp_server=new swoole_server('0.0.0.0', 21414, SWOOLE_BASE, SWOOLE_UDP);
$udp_server->on('packet', function ($ipsock, $data, $ipsock_con) /* use(&$ch) */
{
//echo $data."=========sent====\n\n";
if ($ipsock_con['port']!=21406)
{
$ipsock->sendto('127.0.0.1', 21406, $data); //to wg
@diyism
diyism / create multiple servers with php swoole.php
Created Dec 6, 2019
create multiple servers with php swoole
View create multiple servers with php swoole.php
<?php
/*
open two udp servers and two tcp servers simultaneously with swoole
to test them from linux shell:
$nc -u 127.0.0.1 21404
helloooo_udp
helloooo_udp
...
@diyism
diyism / auto connect between bt300 glasses and linux pc through usb cable for vnc.txt
Last active Jul 15, 2019
auto connect between bt300 glasses and linux pc through usb cable for desktop VNC
View auto connect between bt300 glasses and linux pc through usb cable for vnc.txt
1.===============================/etc/udev/rules.d/70-adb.rules:
SUBSYSTEM=="usb", ATTR{idVendor}=="8087", ATTR{idProduct}=="0a63", GROUP="plugdev", MODE="0666"
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee7", GROUP="plugdev", MODE="0666"
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee4", GROUP="plugdev", MODE="0666"
SUBSYSTEM=="usb", ATTR{idVendor}=="8087", ATTR{idProduct}=="0a63", ACTION=="add", RUN+="/sbin/ifconfig usb0 192.168.42.1 up"
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee4", ACTION=="add", RUN+="/sbin/ifconfig usb0 192.168.42.1 up"
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee7", ACTION=="add", RUN+="/usr/bin/rehtet"
#run:
sudo usermod -aG plugdev malcolm
@diyism
diyism / dns2https.swoole4.php
Last active Mar 19, 2019
dns2https.swoole4.php
View dns2https.swoole4.php
<?php
/*
udp/tcp dns client for google dns over https (https://dns.google.com)
ubuntu上使用:
在/etc/rc.local里加/usr/bin/php /home/<your_name>/dns2https.php
执行:
systemctl disable unbound
systemctl disable dnscrypt-proxy
@diyism
diyism / aes-256-cbc _ encrypt integer _ shorten integer.php
Last active Mar 13, 2019
aes-256-cbc / encrypt integer / shorten integer in php
View aes-256-cbc _ encrypt integer _ shorten integer.php
<?php
$enc=encrypt_int(3524, 'aaaa1111bbbb3333cccc5555dddd7777');
echo $enc.'<hr>';
$int=decrypt_int($enc, 'aaaa1111bbbb3333cccc5555dddd7777');
echo $int.'<hr>';
//输出: 5e91d2b65b2a<hr>3524<hr>
//输出: a08f854f3ddf<hr>3524<hr>
//...
//实际的$iv_short.$ac_short, $crypt_text 分别是:
//5e91d2b6, 5b2a
@diyism
diyism / coroutine vs callback (php7.3+swoole4.3.0).php
Last active Mar 26, 2019
coroutine vs callback (php7.3+swoole4.3.0)
View coroutine vs callback (php7.3+swoole4.3.0).php
<?php
/*===========compile php7.3+swoole4.3.0===============
$sudo apt-get install re2c bison autoconf zlib1g-dev libssl-dev libcurl4-openssl-dev libargon2-0-dev libsodium-dev
$git clone -b PHP-7.3 --depth 1 https://github.com/php/php-src.git
$cd php-src/
$mkdir ext/swoole && curl -s "https://codeload.github.com/swoole/swoole-src/tar.gz/v4.3.0" | tar xvz --strip 1 -C ext/swoole
$./buildconf --force
$./configure --prefix=/usr/local/php7 --disable-all --enable-cli --disable-cgi --disable-fpm --disable-phpdbg --enable-bcmath --enable-hash --enable-json --enable-mbstring --enable-mbregex --enable-mbregex-backtrack --enable-sockets --enable-pdo --with-sodium --with-password-argon2 --with-sqlite3 --with-pdo-sqlite --with-pcre-regex --with-zlib --with-openssl-dir --enable-openssl --enable-swoole
$time make -j `cat /proc/cpuinfo | grep processor | wc -l`
$sudo make install
@diyism
diyism / set_overcommit_ratio.php
Created Jan 28, 2019
set_overcommit_ratio.php
View set_overcommit_ratio.php
<?php
//sudo crontab -e 里加"* * * * * /usr/bin/php /home/malcolm/set_overcommit_ratio.php"
//MemFree需要保留200MB给系统(否则iowait很高桌面就卡住了), Cached有一部份是释放不掉的, 只能先用drop_caches释放下然后计算剩余内存时就不用算Cached的可释放部分了,
//预算超占率采用130%(firefox新开一个标签页时的超占率130%, chrome新开一个标签页是145%), 这个值是非常保守的, sublime,firefox等程序启动都在190%到220%之间, 也是考虑到每分钟才跑一次预占超出去了后再强行缩小会导致/usr/bin/X挂掉
$start_time=time();
shell_exec('sync && echo 3 > /proc/sys/vm/drop_caches');
$mems=array();
$tmp=explode("\n", trim(shell_exec('cat /proc/meminfo | grep -P "Mem|Commit|Cached"')));
foreach ($tmp as $v)
{
View rust_xlib_practice.rs
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_imports)]
extern crate x11_dl;
use std::ffi::CString;
use x11_dl::xlib::{True, False, GrabModeAsync, CurrentTime, XEvent};
use x11_dl::xf86vmode::XF86VidModeModeInfo;
@diyism
diyism / try_boltdb.go
Created Jan 4, 2019
give a try to boltDB(storm), so easy
View try_boltdb.go
package main
//go get -u github.com/asdine/storm
//go run try_boltdb.go
import (
"fmt"
"github.com/asdine/storm"
)
@diyism
diyism / blockchain_ramble.md
Last active Jan 17, 2020
blockchain ramble
View blockchain_ramble.md

区块链漫谈


前言

    作为一个普通程序员 或者说 普通的IT从业者,如何掌握 新技术和新思维,我认为最重要的还是勇敢, 智力的本质是勇敢, 勇敢地闯入无人之地.
    可能有很多同学对区块链的理解比我更深更广, 但是为了提高自己的认识, 我积极地收集资料准备了这次演讲,
    但是后面都是我一家之言, 谬误之处还请大家海涵, 希望抛砖引玉可以把 chelun.co /车轮锟 兴趣小组搞起来.

    解释一个名词, 分布式共识货币, 或简称分布式货币, 也就是流行的"数字货币"/"加密货币",
    但我觉得这些称呼都没有抓住要点, 所以我更愿意称呼"分布式货币".
You can’t perform that action at this time.