Skip to content

Instantly share code, notes, and snippets.

@gainskills
gainskills / z-shell- unsetopt nomatch
Last active March 5, 2020 22:13
Notes about Shell
ZSh is default shell on MAC OS now.
Refert to https://github.com/ohmyzsh/ohmyzsh/issues/31
Execute "unsetopt nomatch" before run curl command, otherwise, it might prompots the error: \
"zsh: no matches found:"
when sending a request with argument like: "curl http://127.0.0.1:8080/test?message=test"
Reason: zsh interprets the ? as a wildcard
@gainskills
gainskills / Routers.cfg
Created December 19, 2018 13:24
IPSec Over Palo Alto FW Static NAT
#---- R5
!
hostname LAN-R5
!
enable password kztest
!
no ip domain lookup
ip domain name kztest.com
!
interface Loopback0
@gainskills
gainskills / Ansible cmd
Last active July 11, 2020 21:24
Sample about Ansible telnet
#telnet part1
ansible-playbook -i inventory_telnet.yml pb_telnet.yml
#Telnet Part2
ansible-playbook -i inventory_telnet.yml --vault-id test@prompt pb_telnet.yml
#SSH
ansible-playbook -i inventory_ssh.yml pb_first.yml
ansible-playbook -i inventory_ssh.yml --vault-id test@prompt pb_first.yml
@gainskills
gainskills / HTTP HTTPs site-POPs.py
Created July 29, 2018 12:26
HTTP/HTTPs site-POPs
import requests
from forcediphttpsadapter.adapters import ForcedIPHTTPSAdapter
import urllib3
urllib3.disable_warnings()
def test1():
ip_list = [
'1.1.1.1',
'2.2.2.1',
'3.3.3.1',
====================
Outside Router:
crypto isakmp policy 10
encr 3des
authentication pre-share
group 2
crypto isakmp key vpnnatkey1 address 192.168.22.1
crypto isakmp key vpnpatkey1 address 192.168.33.1
!
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from email.header import Header
from email.utils import formataddr
sender = "mySendEmail1"
receiver = "myRecEmail1"
pwd = 'mypwd'
Fix the error:
main-loop: WARNING: I/O thread spun for 1000 iterations
Alternative: run ASA9 on EVE/UNL, EVE version: 2.0.3-86
Refer to http://www.fixedbyvonnie.com/2015/05/how-to-setup-an-5520-asa-5-2-in-gns-3-version-1-3/#.WnwYwZNuYWo
Update the parameters:
1. RAM which should be 1,024MB
2. Qemu binary: 2.9 and the x86_64 version
import requests
import time
import os
from selenium import webdriver
from PIL import Image
from io import BytesIO
url = "https://unsplash.com"
driver = webdriver.Firefox(executable_path=r'geckodriver')
import pytz
from datetime import datetime
eastern = pytz.timezone('US/Eastern')
cutime = datetime.now(eastern)
timestr = cutime.strftime("%Y-%m-%d")
@gainskills
gainskills / osop1.py
Last active November 4, 2016 12:36
Python copy folders/kill process/start service
import os
import shutil
'''
administrator privliedge is needed
'''
def cpfolder(srcpath, dstpath):
try:
shutil.copytree(srcpath, dstpath)