Skip to content

Instantly share code, notes, and snippets.

@jwc20
Last active April 21, 2024 10:40
Show Gist options
  • Save jwc20/385832b030e6d97b94c848bc64ba24a9 to your computer and use it in GitHub Desktop.
Save jwc20/385832b030e6d97b94c848bc64ba24a9 to your computer and use it in GitHub Desktop.
export PYTHONPATH=$SCM_PATH/py
SHELL_NAME="\[\033[01;91m\]($name)\[\033[00m\]"
# https://gist.github.com/ckabalan/2732cf6368a0adfbe55f03be33286ab1
# Color codes for easy prompt building
COLOR_DIVIDER="\[\e[30;1m\]"
COLOR_CMDCOUNT="\[\e[34;1m\]"
COLOR_USERNAME="\[\e[34;1m\]"
COLOR_USERHOSTAT="\[\e[34;1m\]"
COLOR_HOSTNAME="\[\e[34;1m\]"
COLOR_GITBRANCH="\[\e[33;1m\]"
COLOR_VENV="\[\e[33;1m\]"
COLOR_GREEN="\[\e[32;1m\]"
COLOR_PATH_OK="\[\e[32;1m\]"
COLOR_PATH_ERR="\[\e[31;1m\]"
COLOR_NONE="\[\e[0m\]"
# Change the path color based on return value.
if test $? -eq 0 ; then
PATH_COLOR=${COLOR_PATH_OK}
else
PATH_COLOR=${COLOR_PATH_ERR}
fi
# Set the PS1 to be "[workingdirectory:commandcount"
PS1="${COLOR_DIVIDER}[${PATH_COLOR}\w${COLOR_DIVIDER}:${COLOR_CMDCOUNT}\#${COLOR_DIVIDER}"
# Add git branch portion of the prompt, this adds ":branchname"
if ! git_loc="$(type -p "$git_command_name")" || [ -z "$git_loc" ]; then
# Git is installed
if [ -d .git ] || git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
# Inside of a git repository
GIT_BRANCH=$(git symbolic-ref --short HEAD)
PS1="${PS1}:${COLOR_GITBRANCH}${GIT_BRANCH}${COLOR_DIVIDER}"
fi
fi
# Add Python VirtualEnv portion of the prompt, this adds ":venvname"
if ! test -z "$VIRTUAL_ENV" ; then
PS1="${PS1}:${COLOR_VENV}`basename \"$VIRTUAL_ENV\"`${COLOR_DIVIDER}"
fi
# Close out the prompt, this adds "]\n[username@hostname] "
PS1="${SHELL_NAME} ${PS1}]\n${COLOR_DIVIDER}[${COLOR_USERNAME}\u${COLOR_USERHOSTAT}@${COLOR_HOSTNAME}\h${COLOR_DIVIDER}]${COLOR_NONE} "
alias vi='nvim'
alias cl='clear'
let
pkgs = (import (builtins.fetchTarball {
name= "nixos-23.11-stable-20240406";
url = "https://github.com/NixOS/nixpkgs/archive/e38d7cb66ea4f7a0eb6681920615dfcc30fc2920.tar.gz";
sha256 = "1shml3mf52smfra0x3mpfixddr4krp3n78fc2sv07ghiphn22k43";
}) { });
stdenv = pkgs.stdenv;
in pkgs.mkShell rec {
name = "nix-shell";
shellHook = ''
source .bashrc
'';
buildInputs = (with pkgs; [
bashInteractive
curl
git
gnugrep
lazygit
nix-prefetch-scripts
neovim # => get settings from ~/.config/nvim/init.vim
tmux
tree
which
(pkgs.python3.buildEnv.override {
ignoreCollisions = true;
extraLibs = with pkgs.python3.pkgs; [
beautifulsoup4
lxml
pprintpp
python-dotenv
requests
selenium
];
})
]);
}
@jwc20
Copy link
Author

jwc20 commented Apr 13, 2024

To use chrome web driver in selenium:

Install Chrome Browser
Chrome for Testing (Check for latest version)

Install chromedriver:

# for ubuntu
# wget https://chromedriver.storage.googleapis.com/{version}/chromedriver_linux64.zip
wget https://chromedriver.storage.googleapis.com/123.0.6312.122/chromedriver_linux64.zip

unzip chromedriver_linux64.zip

sudo mv chromedriver-linux64 /usr/bin/chromedriver-linux64

sudo chown root:root /usr/bin/chromedriver-linux64
sudo chmod +x /usr/bin/chromedriver-linux64

Then get in python:

chrome_driver_path = '/usr/bin/chromedriver-linux64/chromedriver'
self.driver = webdriver.Chrome(service=Service(chrome_driver_path))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment