Posts

Showing posts from January, 2021

Can't find the code you're looking for? Just Suggest a Snippet and I'll add it :)

Setup Jenkins on Ubuntu 18.04 on AWS Lightsail

I couldn't find a guide for this - and I had to do this recently. So here goes! 1. Install Java sudo apt update && sudo apt install -y openjdk-8-jdk 2. Add the Jenkins Debian repository wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add - 3. Add the repo to system sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list' 4. Install Jenkins sudo apt update sudo apt install jenkins systemctl status jenkins 5. Add firewall rule In AWS lightsail > click on instance

SNAPPED!

Multi Line Comments Python

Multi Line Comments """ This is a comment This is a comment """

SNAPPED!

python print

python print print("Hi")

SNAPPED!

Commenting in Python

#This is a comment

SNAPPED!

Big list of selenium options + injecting cookies for testing

Use these options as you need! import csv import random import time from selenium.webdriver.chrome.options import Options from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.common.exceptions import NoSuchElementException import pickle option = Options() # option.add_argument("headless") # option.add_argument("window-size=1980,960") # option.add_argument("screenshot") # option.add_argument( # "user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36") # option.add_argument("--enable-javascript") # option.add_argument("--disable-infobars") # option.add_argument("start-maximized") # option.add_argument("--disable-extensions") # option.add_argument("--start-maximized") # option.add_argument(&quo

SNAPPED!

Iterate or go through all files in a directory python

TEXT import os from tqdm import tqdm for filename in tqdm(os.listdir(directory)): if filename.endswith(".csv"): fp = os.path.join(directory, filename)

SNAPPED!

Deduplicate files all folders ubuntu

Use the awesome fdupes package: fdupes --noprompt -d -r ~/folder

SNAPPED!

Python requests passing JSON data (for API) boilerplate

Python requests passing JSON data (for API) boilerplate import requests payload = {'key1': 'value1', 'key2': 'value2'} r = requests.get('https://httpbin.org/get', params=payload)

SNAPPED!

Python requests

Python requests boilerplate import requests url = 'URL_HERE' response = requests.get(url) print(url.status_code) content = response.content print(content)

SNAPPED!

Popular posts from this blog

Append to a json file python

Setup Mailhog mail server on Ubuntu