Skip to content

Instantly share code, notes, and snippets.

@xbns
xbns / search-user-api.py
Last active January 7, 2019 08:01
search user given api endpoint
import requests
import json
import csv
token = ''
program_id = ''
def get_auth_token(token,program_id):
endpoint = 'https://xxx.mycompany.yy/auth/login'
payload = {
@xbns
xbns / create-user-order.py
Last active November 18, 2020 15:04
create random user and order via API
import requests
import names
import random
import json
token = ''
#program_id = ''
program_id = '2ba0d47c-dea6-11e8-b2b3-06f77de3a7f0' # Test Program
location_id = '09942cd5-f100-42c3-a175-cd620cd3bc7c' # Kilimani
@xbns
xbns / download-pdfs.py
Last active June 6, 2019 09:49
#parallel #scraping pdfs
from bs4 import BeautifulSoup
import requests
r = requests.get("https://aws.amazon.com/whitepapers/")
data = r.text
soup = BeautifulSoup(data,"lxml")
for link in soup.findAll('a',href=True):
#skip all other liks except pdf ones
if not link['href'].endswith('pdf'):
@xbns
xbns / replace.py
Created June 6, 2019 08:27
#replace text #files
import fileinput
#Read in the file
with open('aws-whitepapers.txt','r') as file:
filedata=file.read()
#Replace the target string
filedata = filedata.replace('//','https://')
#Write the file out again
@xbns
xbns / verify-message.py
Last active January 10, 2024 19:29
#tech
"""
__author_ = "Josphat Mutuku"
__date__ ="2019-07-03"
"""
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException
import unittest
@xbns
xbns / postman_api_test.js
Last active November 23, 2022 12:14
token auth [postman token authentication automation ]#postman
const lodash = require('lodash')
pm.test("Validate Response to be 200 OK", function () {
pm.response.to.have.status(200);
});
pm.test("Validate Response Time to be less than 200ms", function () {
pm.expect(pm.response.responseTime).to.be.below(200);
});
@xbns
xbns / users.py
Last active April 15, 2024 10:28
#tech
"""
__author_ = "Josphat Mutuku"
__date__ ="2019-07-03"
"""
import requests
import unittest
import json
import ijson
@xbns
xbns / get_credit_score.py
Last active December 7, 2020 10:49
[credit scoring] Credit Score Script #credit-score #csv #json
import requests
from requests.auth import HTTPBasicAuth
import json
import csv
import logging
import sys
from logging.handlers import TimedRotatingFileHandler
FORMATTER = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
LOG_FILE = 'my_app.log'
@xbns
xbns / jsonTocsv.py
Created September 26, 2019 09:15
#jsonTocsv #snippet
import json
import sys
from flatten_json import flatten
import pandas as pd
#check if you pass the input file
if sys.argv[1] is not None:
fileInput = sys.argv[1]
inputFile = open(fileInput) #open json file
@xbns
xbns / disk-partitioning.md
Created November 8, 2019 10:39
#disk-partition

/root

  • A 12 - 20 GB partition for the OS,which gets mounted as /(called "root").
  • maximum of 20 GB for root partition should always be enough even if you install a ton of software.
  • Most distributions of Linux use either ext3 or ext4 as their file system nowadays, which has a built-in “self-cleaning” mechanism so you don’t have to defrag.
  • In order for this to work best, though, there should be free space for between 25-35% of the partition. (20% x 20 = 4GB) (35% x 20 = 7GB)