Skip to content

Instantly share code, notes, and snippets.

@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 / frp systemd.md
Last active December 26, 2023 05:13
FRP systemd 启动脚本 FRP systemd init config
@ihipop
ihipop / pop_de_pgp.md
Created May 7, 2018 06:42
ihipop的PGP KEY
@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 / 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 / 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 / grok.md
Last active March 21, 2017 02:59
Logstash grok Patterns
NGINXACCESS_WITH_FORWARD_HOST %{IPORHOST:remote_addr}(\:%{INT:remote_port})? - %{USERNAME:remote_user} \[%{HTTPDATE:time_local}\] "(?:%{WORD:method} %{NOTSPACE:request}(?: HTTP/%{NUMBER:http_version})?|%{DATA:rawrequest})" %{INT:status} %{INT:bytes_sent} %{QS:http_referer} %{QS:http_user_agent} %{QS:http_x_forwarded_for} "%{IPORHOST:http_host}"

this works for

10.88.1.12 - - [07/Jan/2017:12:13:33 +0800] "GET / HTTP/1.1" 200 21783 "http://example.com/refererUrl" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36" "1.2.3.4,4.5.6.7" "www.example2.com" 
10.88.1.12:8123 - - [07/Jan/2017:12:13:33 +0800] "GET / HTTP/1.1" 200 21783 "http://example.com/refererUrl2" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36" "1.2.3.4,4.5.6.7" "www.example3.com" 
@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 / awk中的时间处理例子.md
Last active November 4, 2016 09:15
awk中的时间处理例子

条件: 样本数据expr.txt列数未知 第一列是年份日期,第二列是时间,要求把第一二列整体代表的所在日期时间提前7583580秒(大约87.7天) 其他列原样输出

$ cat expr.txt 
2016-11-04 12:03 1478232180 col2 col2 col3
2016-08-08 17:30 1470648600 col2 none

例子如下

$ awk '{gsub(/-/," ",$1 );gsub(/:/," ",$2);d=$1" "$2" 00";d=mktime(d);d=d + 7583580;d=strftime("%Y-%m-%d %H:%M",d);out="";for (i=3;i&lt;=NF;i++){out=out" "$i};print d" "out }' expr.txt