Skip to content

Instantly share code, notes, and snippets.

@ihipop
ihipop / Fly.sh
Last active July 23, 2019 06:32
SSR-manyuser None Auto Script for Ubuntu 16.04 LTS Only
#!/bin/bash
set -eu
install_dir=${install_dir:-'/opt/ihipop/'}
run_user=${run_user:-'www-data'}
[[ "${install_dir}" = "" || "${install_dir}" = "/" ]] && { echo install_dir ${install_dir} is not Valid ;exit 1;}
function trim() {
local var="$*"
# remove leading whitespace characters
var="${var#"${var%%[![:space:]]*}"}"
@ihipop
ihipop / swoole-process-socket-with-Coroutine.php
Created April 23, 2019 03:19
协程安全的进程通讯 With Swoole
<?php
Swoole\Runtime::enableCoroutine();
$processContainer = [];
for ($i = 0; $i < 2; $i++) {
$process = new \Swoole\Process(function (\Swoole\Process $workerProcess) {
\Swoole\Coroutine::create(function () use ($workerProcess) {
while (true) {
$socket = $workerProcess->exportSocket();
$pid = posix_getpid();
echo 'Idle:' . $pid . PHP_EOL;
@ihipop
ihipop / youzan-express.json
Last active November 28, 2018 02:36
有赞快递.json
{
"response": {
"allExpress": [
{
"display": 1,
"name": "申通快递",
"id": 1
},
{
"display": 1,
@ihipop
ihipop / test-hash-map.php
Last active August 29, 2018 12:01
测试 php 的 hash_map / 纯数组 查找元素速度和资源占用情况
<?php
function create_uuid()
{
$str = md5(uniqid(mt_rand(), true));
$uuid = substr($str, 0, 8) . '-';
$uuid .= substr($str, 8, 4) . '-';
$uuid .= substr($str, 12, 4) . '-';
$uuid .= substr($str, 16, 4) . '-';
$uuid .= substr($str, 20, 12);
@ihipop
ihipop / psysh.md
Last active August 25, 2018 15:49
psysh配置

~/.config/psysh/config.php

<?php
return call_user_func(function () {
    $defaultIncludes    = [];
    $composerAutoload   = [];
    $composerAutoload[] = (getenv("COMPOSER_HOME") ?: getenv("HOME") . '/.composer/') . '/vendor/autoload.php';
    $composerAutoload[] = getcwd() . DIRECTORY_SEPARATOR . '/vendor/autoload.php';
 foreach ($composerAutoload as $autoloader) {
@ihipop
ihipop / wangka.py
Last active June 25, 2018 07:28
王卡选号程序
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
# Created on 2016-11-23
# ihipop@gmail.com
import requests, time, random, json
from pprint import pprint
import logging
@ihipop
ihipop / firefox.desktop
Last active May 18, 2018 03:53
firefox.desktop file
[Desktop Entry]
Encoding=UTF-8
Name=Firefox
Name[bg]=Firefox
Name[ca]=Firefox
Name[cs]=Firefox
Name[el]=Firefox
Name[es]=Firefox
Name[fa]=Firefox
Name[fi]=Firefox
@ihipop
ihipop / pop_de_pgp.md
Created May 7, 2018 06:42
ihipop的PGP KEY
@ihipop
ihipop / touchpad_toggle.sh
Last active January 24, 2018 08:08
热键开关触摸板 touchpad_toggle
#!/bin/bash
#touchpad_toggle.sh
action=${1:-'auto'}
#echo $action;
declare -i ID
ID=`xinput list | grep -Eio '(touchpad|glidepoint)\s*id\=[0-9]{1,2}' | grep -Eo '[0-9]{1,2}'`
declare -i STATE
if [ "$action" == "off" ];then
STATE=1;
elif [ "$action" == "on" ];then
@ihipop
ihipop / phantomjs CJK Font.md
Last active May 9, 2017 08:10
phantomjs CJK Font
apt-get install fonts-droid-fallback ttf-wqy-zenhei ttf-wqy-microhei fonts-arphic-ukai fonts-arphic-uming xfonts-wqy ttf-mscorefonts-installer \
fonts-noto-cjk

IN Ubuntu 16.04 LTS