- 博客(183)
- 收藏
- 关注
原创 用Python写一个实时显示网速的图形程序
需要用到库python3用tkinter, python2用Tkinterpsutil思路利用psutil获取到第一个网卡, 然后获取传入传出的流量, 单位是字节(byte), 一般都是KB, 也就是一千个字节来显示比较普遍, 所以后面有除以1024;用while循环, 每隔一秒来刷新;tkinter中按钮绑定的方法作为一个中间方法, 先开启一个线程, 然后在执行实际的代码, 这样图形界面也不会卡顿.下面是实际的代码# _*_ coding: utf-8 _*_# @Author : otfsenter
2022-01-27 23:35:35
726
原创 python logging configure with config.py
a = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'standard': { 'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s' }, }...
2019-06-03 00:31:00
266
原创 git custom repository
adduser gitmkdir /gitcd /gitgit init --bare sample.gitchown -R git:git sample.gitif port custom:git clone ssh://git@remote_ip:remote_port/git/download.git mastergit push ssh://git@remote...
2018-10-31 21:58:00
166
原创 run docker all the time
docker run -d -p 8081:8081 centos:latest /usr/bin/bash -c "trap : TERM INT; sleep infinity & wait"
2018-10-27 23:41:00
195
原创 nodejs init config
config npmnpm config lsnpm config set cache "D:\nodejs\node_cache"npm config set prefix "D:\nodejs\node_global"config environmentNODE_HOME = "D:\nodejs"%NODE_HOME%\;%NODE_HOME%\node_cache\;...
2018-10-24 11:17:00
349
原创 config https in nginx(free)
get server.key with passwordopenssl genrsa -des3 -out server.key 2048get server.key no passwordopenssl rsa -in server.key -out server.keyget server.csropenssl req -new -key server.key -out s...
2018-09-29 12:45:00
101
原创 js hex string to unicode string
var origin_str = "e4bda061e5a5bd62";var dec2utf8 = function (arr) { if (typeof arr === 'string') { return arr; } var unicodeString = '', _arr = arr; for (var i = 0; i ...
2018-09-28 18:18:00
241
原创 install gettext on windows
1-https://stackoverflow.com/questions/27220052/django-i18n-make-sure-you-have-gnu-gettext-tools2- download gettextgettext-runtime_0.18.1.1-2_win32gettext-tools-dev_0.18.1.1-2_win32download...
2018-09-25 12:03:00
369
原创 alter character set
alter database blog character set utf8 collate utf8_general_ci;
2018-09-24 21:03:00
175
原创 Git push without username and password
ssh-keygen -t rsapaste key to github websiteafter config ssh keygit remote set-url origin git@github.com:username/repo.git
2018-09-23 14:32:00
128
原创 use iptables instead of firewalld
1- stop firewalldsystemctl stop firewalldsystemctl mask firewalld2- install iptablesyum install iptables-services -ysystemctl enable iptablessystemctl start iptables3- accept 80, 22, 8080...
2018-09-21 11:49:00
113
原创 ssh public key to login server
/etc/ssh/sshd_configRSAAuthentication yes # 启用 RSA 认证,默认为yesPubkeyAuthentication yes # 启用公钥认证,默认为yesgenerate client public and private key ssh-keygen -t rsaStep 3cat id_rsa.pub...
2018-09-20 23:51:00
203
原创 use paramiko to connect remote server and execute command
#!/usr/bin/env pythonimport sys, paramikohostname = ''password = ''command = 'ls'username = ""port = 22try: client = paramiko.SSHClient() client.load_system_host_keys() cli...
2018-09-19 23:32:00
165
原创 protect golang source code
go build -ldflags "-s -w” [<your/package]go tool objdump [-s symregexp] binary
2018-09-18 23:01:00
169
原创 adjust jedi vim to python2 and python3
let py_version = system('python -V 2>&1 | grep -Po " (?<=Python )[2|3] " ' )if py_version == 2 python passelseif py_version == 3 python3 passelse python passendif
2018-09-13 11:30:00
123
原创 install vim plugin local file offline
download github file.zipcd filegit initgit add .git commit -m "init"set rtp+=$HOME/.vim/bundle/Vundle.vim/call vundle#begin('$HOME/.vim/bundle/')Plugin 'file://D:/mtl/vim/jedi-vim'ca...
2018-09-11 13:25:00
157
原创 add swap file if you only have 1G RAM
dd if=/dev/zero of=/swapfile1 bs=1024 count=524288mkswap /swapfile1swapon /swapfile1vi /etc/fstab# edit /etc/fstab file, add the following line/swapfile1 none swap sw 0 0# save and qu...
2018-09-11 12:33:00
134
原创 datatables hyperlink in td
$(document).ready(function () { $('#example').DataTable({ "ajax": "http://127.0.0.1:8080/api/resources/", "columns": [ { "data": "name", ...
2018-09-07 20:07:00
73
原创 django rest framework custom json format
class ResourceSetView(viewsets.ModelViewSet): queryset = models.Resources.objects.all() serializer_class = serializers.ResourceSerializer def list(self, request, *args, **kwargs): ...
2018-09-07 19:15:00
128
原创 optimize the access speed of django website
1- ajax2- move operation of logic move to javascript3- rename django.fcgi to dispatch.fcgi4- optimize sql 5- reduce the size of html * inline css * <head><base target="_blank...
2018-09-04 15:27:00
94
原创 dowload image from requests
import requests import shutil url_png = "http://...png"path_image = "/usr/local/001"resp = requests.get(url, stream=True)with open(path_image, 'wb') as f: shutil.copyfileobj(resp.r...
2018-08-30 18:26:00
80
原创 run jupyter from command
jupyter nbconvert --to script --execute --stdout test_nbconvert.ipynb | python
2018-08-29 18:38:00
110
原创 crawl wechat page
#!/usr/bin/python# coding: utf-8import refrom collections import Counterimport requestsimport timefrom bs4 import BeautifulSoupdef count_zero(text): zero = dict(Counter(text)).get('...
2018-08-28 15:24:00
107
原创 python version 2.7 required which was not found in the registry windows 7
HKEY_CURRENT_USER\Software\Python\PythonCore\2.7\InstallPath default: D:\Python\ ExecutablePath: D:\Python\python.exe WindowedExecutablePath: D:\Python\pythonw.exeHKEY_CURRENT_USER\...
2018-08-22 17:15:00
74
原创 health
import tkinterimport timeclass Reminder: def __init__(self, text): self.root = tkinter.Tk() self.root.overrideredirect(True) self.root.geometry('{0}x{1}+0+0'.forma...
2018-08-20 11:07:00
88
原创 word
inspectioncareful examination or scrutiny.examinationa detailed inspection or study.scrutinycritical observation or examination.
2018-08-15 16:30:00
147
原创 proxy settings
Windows Registry Editor Version 5.00[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Internet Settings]"ProxyEnable"=dword:00000001"ProxyServer"="openproxy.otfsneter.com:8080""P...
2018-08-07 15:48:00
537
原创 mount storage
1- fdisk -lquery storage information include device name and capacity```...Disk /dev/bala: 200GB......```2- confirm /dev/bala is existed file system```file -s /dev/bala``````if ```/...
2018-08-06 14:21:00
151
原创 switch different input method
1- delete registryWindows Registry Editor Version 5.00[HKEY_CURRENT_USER\Control Panel\Input Method\Hot Keys][HKEY_CURRENT_USER\Control Panel\Input Method\Hot Keys\00000010]"Key Modifiers"=...
2018-08-06 10:25:00
237
原创 emacs common configurations
1- show line numbers(setq-default display-line-numbers t)2- no backup files(setq-default make-backup-files nil
2018-08-03 14:01:00
63
原创 use bat file to write csv with sql data
1- write sql that will get data to csvfile name: allsql.sqlSET PAGESIZE 0;SET LINESIZE 5000;SET TRIMSPOOL ON;SET TERMOUT OFF;SET TIMING OFF;SET FEEDBACK OFF;spool file.csv;# there are ...
2018-08-03 13:20:00
97
原创 install emacs
address: http://ftp.gnu.org/pub/gnu/emacs/ file: emacs-26.1.tar.gz yum -y groupinstall "Development Tools" yum -y install gtk+-devel gtk2-devel yum -y install libXpm-devel yum...
2018-08-02 12:50:00
118
原创 add gvim to right context
gvim.regWindows Registry Editor Version 5.00[HKEY_CLASSES_ROOT\*\shell\gVim]@="Edit with Vim(&V)""icon"="\"E:\\gvim\\vim81\\gvim.exe\""[HKEY_CLASSES_ROOT\*\shell\gVim\command]@="\"E:\...
2018-08-01 23:29:00
77
原创 cannot focus element
from selenium.webdriver.common.action_chains import ActionChainsimport timefrom selenium import webdriverdriver = webdriver.Chrome()tip_id = 'Tip_12340128'tip_1 = driver.find_element_by_x...
2018-07-31 16:14:00
228
原创 decompile pyc or pyo file
pip install uncompyle6uncompyle6 *compiled-python-file-pyc-or-pyo*
2018-07-29 22:48:00
119
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人