發表文章

Automatically classify folders by file name (windows Bash)

  REM List file names, sorted by file name--------- dir /b /on > list.txt REM Find JPG files findstr ".JPG" list.txt > target.txt rem delete file extension------------------------- @echo off & setlocal enabledelayedexpansion rem reads all the contents of target.txt for /f "eol=* tokens=*" %%i in (target.txt) do ( rem sets variable a to the content of each line set a=%%i rem If the line has .JPG, change it to set "a=!a:.JPG=!" rem saves all modified lines into $ echo !a!>>$) rem replaces the original a.txt content with the content of $ move $ target.txt REM Create folder----------------------------- rem reads all the contents of target.txt for /f "eol=* tokens=*" %%i in (target.txt) do ( set string=%%i echo "%%i" for /f "tokens=1,2 delims=_" %%a in ("%%i") do ( set BEFORE_UNDERSCORE=%%a set AFTER_UNDERSCORE=%%b echo %%a md %%a rem Move files to folder move %%i*.* %%a )) del list.txt del target.txt

Blocking software access to the Internet

圖片
  第一個步驟先打開控制台   在右上角搜尋防火牆 點擊 Windows 防火牆 再點擊左邊下面有個進階設定 會出現以下 點擊左邊輸入規則 再點擊新增規則 點擊程式直接下一步   選擇要禁止的程式 在點下一步   點擊封鎖連線 再按下一步 勾選全部 再點擊下一步   填完直接按完成 這樣軟體就無法聯網囉
 Ubuntu has a mechanism, that is, the installed network card (NIC) will be renamed to another name when the system is booted. Although there is no difference in using it, it is just a little unaccustomed. After booting, we can observe the dmesg log as follows dmesg | grep rename You can see that the following network cards eth0 and eth1 have been renamed to ens160 and ens192: [1.341871] vmxnet3 0000:03:00.0 ens160: renamed from eth0 [1.362582] vmxnet3 0000:0b:00.0 ens192: renamed from eth1 The method of closing is very simple, that is, edit the /etc/default/grub file and change the following parameters: GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0" Update grub.cfg with the following command sudo update-grub change interface configure /etc/network/interfaces

error message : configparser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found: "%)']/following::android.widget.EditText"

 In general analysis, the last sentence is the key point: When reading the configuration file config.ini, there are % caused by   Solution one: Most likely configparser is reading the literal "%" sign in the string. The '%' symbol is used for string interpolation (substitution). If you want to use a literal "%", you can escape it with another "%". For example, use "100%%" to mean "100%" in configuration variables read by configparser. Solution two: Change from cf= configparser.ConfigParser() to : cf = configparser.RawConfigParser()

OSError: [Errno 22] Invalid argument:

1 .  Error message : File "tarfile.py", line 2155, in makefile with bltn_open(targetpath, "wb") as target:  OSError: [Errno 22] Invalid argument:  This looks like a windows problem as colons in filenames are reserved characters in Windows. We don't like the idea of renaming the actual file for the sake of supporting in Windows. We will look into alternatives and track this as an enhancement separately.  2.  Edit tarfile.py :  You should add a line in 2155  # targetpath_s = targetpath.replace(':','-')

Change NAS password on Win10

圖片
  按 win+R 打開 執行 ,輸入 control userpasswords2 ,會變這樣 再按到進階,管理密碼, windows 認證,就可以選要把哪條密碼清除了  

Esxi increase hard drive size (Ubuntu none LVM)

1 .    Install parted if you don't have them using  CI-Server:~$  sudo apt-get install cloud-guest-utils 2.  T urn off swap. we gonna remove it's partition! CI-Server:~$ sudo swapoff -a CI-Server:~$ sudo parted get partitions list with print all: (parted) print all Model: Virtio Block Device (virtblk) Disk /dev/vda: 752GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number  Start   End    Size    Type      File system     Flags 1      1049kB  528GB  528GB   primary   ext4            boot 2      528GB   537GB  8588MB  extended 5      528GB   537GB  8588MB  logical   linux-swap(v1) remove none root partitions with rm (part-index): (parted) rm 5 Warning: Partition /dev/vda5 is being used. Are you sure you want to cont...

How to set /etc/issues to show the IP address of eth0

linux virtual machines with a bridge interface, and I want to display the machine's IP address after the machine is booted (in login, it usually shows the release and kernel). This is just a text file...you write it in the same way you would send text to the file using any other shell script. Something like this will replace /etc/issue with your ip address: ifconfig eth0 | awk '/inet addr/ {print $2}' | cut - f2 - d : > /etc/ issue Obviously, depending on the information you want in /etc/issue, you can make this more complex file at will. You can write to this file using the local equivalent /etc/rc.d/rc.local (usually executed after all other startup scripts). On CentOS 7 and Debian 8, just append the following line to /etc/issue My IP address : \4 This will resolve to the machine’s IPv4 address. If you have multiple network interfaces and want to select a specific network interface, you can use s pecify it My IP address : \4 { eth0 } Check man getty for the li...

Ubuntu 16.04 install OpenVAS 9

1 .  Install OpenVAS PPA Suite Library # apt-get install -y software-properties-common # apt-get install -y python-software-properties # add-apt-repository ppa: mrazavi / openvas 2. Install openvas software # apt-get update # apt-get install -y openvas9 3. Install SQLite3 # apt-get install -y sqlite3 4.  Synchronize the latest vulnerability information of openvas # greenbone-nvt-sync 5.  Syn chronize SCAP and CERT   to the local machine When synchronizing, one IP can only have one session, if it is interrupted and then reconnected, it may be locked # greenbone-scapdata-sync // Synchronized data is stored in / var / lib / openvas / scap-data # greenbone-certdata-sync // Sync data is stored in / var / lib / openvas / cert-data 6. Start the openvas service # /etc/init.d/redis-server restart # service openvas-scanner restart # service openvas-manager restart 7. Rebuild the openvas database # openvasmd --rebuild --progress ...

Ubuntu 18.04.1 mysql password settings, and can be set without sudo login

Description: After installing Ubuntu 18.04.1 , you cannot execute the mysql command as a user.  You must use sudo to execute the mysql directive, and any php program may not be able to connect to mysql. Step1: Login to the mysql interface example: Sudo mysql -uroot -p Enter password: [press Enter directly] Step2:  Modify the account management mode and change password mysql>  Use mysql; mysql>  Update user SET plugin='mysql_native_password' WHERE User='root'; mysql>  Update user set authentication_string=password('root new password') where user='root'; mysql>  Flush privileges; Step3:  After logging out, you can use the following mysql command without adding sudo

Hide black console window

Step1: First package according to common procedures Need pyinstaller example: First reach the location of this scripts cd C:\Python27\Scripts Then enter pyinstaller -F D:\Wayne\file.py --distpath D:\Wayne At this time, the folder will be generated on the desktop. build, dist There is also a protagonist of "Archive.spec" Open "Profile.spec" with Notepad One of them is like this Exe = EXE(pyz,           A.scripts,           A.binaries,           A.zipfiles,           A.datas,           [],           Name='my file',           Debug=False,           Bootloader_ignore_signals=False,           Strip=False,           Upx=True,           Runtime_tmpdir=None,           Conso...

Ubuntu server 安裝 teamviewer 和使用 teamviewer

Step1: create a folder to save, download the TeamViewer installation package mkdir ~/downloads/  cd ~/downloads/  wget https://download.teamviewer.com/download/teamviewer_i386.deb Step2: TeamViewer installation package sudo dpkg -i teamviewer_i386.deb cd /opt/teamviewer/tv_bin Teamviewer --setup console #Set the startup mode to console startup Teamviewer --daemon restart #restart teamview service Sudo teamviewer --passwd 112358 #Set password Teamviewer --info #teamview # View id If you get an error, and the content is as follows: Sudo apt-get install libdbus-1-3:i386 libasound2:i386 libexpat1:i386 libfontconfig1:i386 libfreetype6:i386 libjpeg62:i386 libpng12-0:i386 libsm6:i386 libxdamage1:i386 libxext6:i386 libxfixes3:i Then execute the command: sudo apt-get update sudo apt-get install -f These two commands are fine. After this, it will not succeed. When you log in, you will get an error. Failed to start session You can use Ctrl + Alt +F1 to enter the c...

python 測試框架工具

Python的測試框架 Unit frameworks單元測試框架 Framework unittest   - python自帶的單元測試庫,開箱即用 unittest2   - 加強版的單元測試框架,適用於Python 2.7以及後續版本 pytest   - 成熟且功能強大的單元測試框架 plugincompat   - pytest的執行及兼容性插件 nosetests   - 讓python測試更容易一點 slash   - python實現的單元測試框架 Extension proboscis   - 仿TestNG擴展了unittest模塊以及Nose的功能 grail   -可以讓你一步一步編寫測試用例的庫 Testify   - 單元測試框架,提供了加強型夾具,用例切割並行運行,testrunner高亮及詳盡的日誌和報告功能 trial   - unittest模塊的擴展,提供了命令行的testrunner工具以及代碼覆蓋率的整合,跟鼻差不多 subunit   - 提供了unittest在另一個進程執行用例並彙總測試數據的能力 testresources   - 提供了多用例間管理測試數據的機制,兼容unittest testtools   - 為Twisted和Bazaar提供的unittest擴展 Sancho   - 運行用例,並為失​​敗的用例提供報告,但僅限於此 zope.testing   - testrunner,提供了不錯的debuge能力,並且集成了代碼覆蓋率。可以跟zope項目使用,也可以用在非zope項目上 pythoscope   - 自動或半自動為遺留的python系統創建測試用例的工具 testlib   - 更強大的unittest,更多的斷言,支持模塊級的設置/拆解,跳過測試等... dutest  ...