Skip to content

Instantly share code, notes, and snippets.

View ourway's full-sized avatar
🏆

Farshid Ashouri ourway

🏆
View GitHub Profile
from selenium.common.exceptions import NoSuchElementException, ElementClickInterceptedException
from selenium import webdriver
import time
import pandas as pd
def get_jobs(keyword, num_jobs, verbose):
'''Gathers jobs as a dataframe, scraped from Glassdoor'''
# Initializing the webdriver
@ourway
ourway / pandas cheat sheet.md
Created April 20, 2023 16:09 — forked from fabsta/pandas cheat sheet.md
pandas cheat sheet

[TOC]

Preliminaries/Import

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from pandas import DataFrame, Series
@ourway
ourway / freebsd-qemu-xhyve-mac-os-x-virtual-machine.md
Created October 18, 2021 00:15 — forked from zg/freebsd-qemu-xhyve-mac-os-x-virtual-machine.md
Create FreeBSD virtual machine using qemu. Run the VM using xhyve.

TL;DR

  • Create 10GB FreeBSD image using QEMU.
  • Run the VM using xhyve.
  • Mount host directory.
  • Resize the image.

Requisites

@ourway
ourway / 1.srp.py
Created May 23, 2021 23:57 — forked from dmmeteo/1.srp.py
SOLID Principles explained in Python with examples.
"""
Single Responsibility Principle
“…You had one job” — Loki to Skurge in Thor: Ragnarok
A class should have only one job.
If a class has more than one responsibility, it becomes coupled.
A change to one responsibility results to modification of the other responsibility.
"""
class Animal:
def __init__(self, name: str):
@ourway
ourway / howto.md
Created May 20, 2021 21:51 — forked from evkuzin/howto.md
log_min_duration_statement = 0 and I/O impact

How to get an estimate of the impact of writing Postgres logs with log_min_duration_statement = 0:

  1. Do select pg_stat_statements_reset(); and wait N seconds (where N >> 60 – say 1-24 hours, covering typical busy hours). Remember when it was, and write down somewhere – this timestamp will be needed!

  2. Check if select count(*) from pg_stat_statements is lower than pg_stat_statements.max. If it's equal to it, then raise pg_stat_statements.max and restart with the step 1.

  3. Get the estimate:

\set TS_PGSS_RESET 'XXXX-XX-XX XX:XX:XX';
@ourway
ourway / advanced-psql-examples.sql
Created January 4, 2021 07:58 — forked from marko-asplund/advanced-psql-examples.sql
Advanced PostgreSQL feature examples. Includes table DDL, example data and queries.
--
-- ** setting up example tables and data **
--
--
CREATE TABLE task (
id BIGSERIAL ,
name TEXT,
parent_id BIGINT REFERENCES task(id),
PRIMARY KEY (id)
@ourway
ourway / pytest.ini
Created November 25, 2020 11:54 — forked from tribals/Pipfile
Understanding SQL row locking - `SELECT FOR UPDATE`
[pytest]
log_cli = true
log_cli_date_format = %H:%M:%S
log_cli_format = %(asctime)s.%(msecs)03d %(levelname)-8s %(name)-32s %(threadName)-12s %(message)s
addopts = --quiet --showlocals --tb=short
@ourway
ourway / monoid.py
Created August 18, 2020 20:33 — forked from zeeshanlakhani/monoid.py
Python Monoid
#Code from http://fmota.eu/, great!
class Monoid:
def __init__(self, null, lift, op):
self.null = null
self.lift = lift
self.op = op
def fold(self, xs):
if hasattr(xs, "__fold__"):
return xs.__fold__(self)
@ourway
ourway / convert.py
Last active July 25, 2020 01:26 — forked from nmstoker/convert.py
Convert a Rasa NLU training file from JSON to Markdown format
from rasa_nlu.training_data import load_data
# This re-uses the Rasa NLU converters code to turn a JSON Rasa NLU training
# file into MD format and save it
# Assumes you have Rasa NLU installed :-)
# If you want other options, look at the NLU code to work out how to handle them
# USE AT YOUR OWN RISK
@ourway
ourway / IAPTunneling.md
Created June 19, 2020 12:46 — forked from jjorissen52/IAPTunneling.md
SSH TCP Tunneling using Google Cloud SDK Identity Aware Proxy Commands

Using ssh Command:

# sudo only necessary to bind to protected port such as 80 or 443
sudo gcloud compute ssh <instance_name> -- -N -L 80:localhost:80

Using start-iap-tunnel Command

# sudo only necessary to bind to protected port such as 80 or 443
sudo gcloud compute start-iap-tunnel  80 --local-host-port=localhost:80