Skip to content

Instantly share code, notes, and snippets.

@wbchn
wbchn / chromemobiletest.py
Created April 28, 2018 06:23 — forked from devinmancuso/chromemobiletest.py
Example Python Chrome Mobile Emulation Automated Unit Testing Using Selenium 2 WebDriver ChromeDriver
# Import unittest module for creating unit tests
import unittest
# Import time module to implement
import time
# Import the Selenium 2 module (aka "webdriver")
from selenium import webdriver
# For automating data input
@wbchn
wbchn / python3.6-pip.md
Created March 28, 2018 09:13
Install pip for python3.6 which install with apt

Solution from https://askubuntu.com/questions/889535/how-to-install-pip-for-python-3-6-on-ubuntu-16-10

After install python3.6 via apt install python3.6, pip failure:

$ sudo pip3 install --upgrade pip
Traceback (most recent call last):
  File "/usr/bin/pip3", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1479, in <module>
 register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
-- 1.Setup the device ID and access credential.See later.
 
-- PIN assignment
-- D5 is the driver PIN for the dust detector
dpin = 5
-- D0 is the LED on the NodeMCU board
lpin = 0
gpio.mode(dpin, gpio.INT)
-- The current pulse params
rising_ts = 0
@wbchn
wbchn / npm-install-exepected-input.md
Created December 21, 2017 01:18
解决npm出现`Unexpected end of`错误

ERRORS

I got error like below:

npm ERR! Unexpected end of input at 1:23369

or

npm ERR! Unexpected end of JSON ...

SOLVE

@wbchn
wbchn / ip.php
Created October 17, 2017 10:13
Show HTTP headers
<?php
$array = array('HTTP_USER_AGENT', 'HTTP_HOST', 'HTTP_ACCEPT', 'PATH', 'SERVER_SIGNATURE', 'SERVER_SOFTWARE', 'SERVER_NAME', 'SERVER_ADDR', 'SERVER_PORT', 'DOCUMENT_ROOT', 'SERVER_ADMIN', 'SCRIPT_FILENAME', 'REMOTE_PORT', 'GATEWAY_INTERFACE', 'SERVER_PROTOCOL', 'REQUEST_METHOD', 'QUERY_STRING', 'REQUEST_URI', 'SCRIPT_NAME', 'PHP_SELF', 'REQUEST_TIME');
// 将 $_SERVER 数组赋予 $srv数组;
$srv = $_SERVER;
// 释放掉 $srv中不相关的键
foreach($array as $name ) {
unset($srv[ $name ]);
}
print_r($srv);
@wbchn
wbchn / bbr.sh
Last active February 9, 2023 01:10
DONNOT USING. bbr install script for linux
#!/usr/bin/env bash
#
# Auto install latest kernel for TCP BBR
#
# System Required: CentOS 6+, Debian7+, Ubuntu12+
#
# Copyright (C) 2016-2017 Teddysun <i@teddysun.com>
#
# URL: https://teddysun.com/489.html
#
@wbchn
wbchn / fluentd_k8s_log_to_logzio.conf
Created October 10, 2017 03:17
fluentd: k8s log to logzio
# This configuration file for Fluentd / td-agent is used
# to watch changes to Docker log files that live in the
# directory /var/lib/docker/containers/ and are symbolically
# linked to from the /var/log directory using names that capture the
# pod name and container name. These logs are then submitted to
# Google Cloud Logging which assumes the installation of the cloud-logging plug-in.
#
# This configuration is almost identical to google-fluentd-journal.conf, with
# the one difference being that this doesn't try to collect systemd journal
# logs.
@wbchn
wbchn / setup_fraudenv.sh
Last active May 24, 2017 08:04
azure hdinsight user scripts demo
#!/usr/bin/env bash
GEOIP_WASB_DIR=$1
GEOIPCUSTOM_DIR=/home/sshuser
if [ -z "$GEOIP_WASB_DIR" ]; then
echo "[ERROR] No wasb directory specified. Exiting!"
exit 132
fi
# copy maxmind geoip database
@wbchn
wbchn / sendpcap.py
Created April 20, 2017 06:02
抓包发包,来自网络
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#Resend packets in pcap file
#Created 7/30/2016, thimer
import struct
import socket
import sys
import time
def hexofbin(bin, show=4):
@wbchn
wbchn / webdav.sh
Created April 7, 2017 08:27
webdav mount scripts
#!/bin/sh
[ $# -ne '4' ] && echo -e "Usage:\n bash $0 [WebDAV] [User] [Password] [MountPath]" && exit 1
WebDAV="$1"
User="$2"
Pwd="$3"
WebMount="$4"
apt-get install -y -qq davfs2 fuse-utils libneon27-gnutls
[ $? -ne '0' ] && echo "Install davfs2 fail! " && exit 1
mkdir -p "$WebMount"
rm -rf /etc/davfs2/davfs2.conf