Skip to content

Instantly share code, notes, and snippets.

View GeorgeOduor's full-sized avatar
🌴
On vacation

George Oduor GeorgeOduor

🌴
On vacation
  • Kenyatta University
View GitHub Profile
@GeorgeOduor
GeorgeOduor / LinkedIn Job Scraper with selenium and beautiful soup
Created October 16, 2022 18:40
Scrap Jobs from linked in and save to googlesheets
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from bs4 import BeautifulSoup as bs
from datetime import datetime
import pygsheets
import pandas as pd
from time import sleep
rm(list = ls())
library(pdftools)
library(magick)
library(mbanalytics)
library(R6)
statement = "E:/Reports/improptu/Oct/KaribuStatement.pdf"
# pdf_file <- pdf_convert(statement,pages = 1,dpi = 100)
file = pdf_text(pdf = statement)
rm(list = ls())
library(tidyverse)
library(R6)
# datastes ------
set.seed(1)
population1 = tibble(x = rnorm(20.00, 20, 5),
y = rnorm(20.00, 15, 5),)
population2 = tibble(x = rpois(3231, 50),
y = rnorm(3231, 45),)
---
title: "Basic Statistics"
author: "George"
date: "8/2/2021"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
@GeorgeOduor
GeorgeOduor / OOP in R,simulating a simple banking system
Last active June 14, 2021 14:43
This script is an illustration of Object oriented programming in R.It simulates a simple core banking system in R
# This script simulates a simple core banking system in R.Its an illustration of Object oriented programming in R
CBS <- R6Class(classname = "CBS",public = list(
accs = tibble("Full Name" = NA,"IDNo" = NA,'AccountNo' = NA,'AccountBalance' = NA,'LoanBalance' = NA),
bank_name = NA,
initialize = function(accs = NULL,bank_name) {
self$bank_name = bank_name
cat(paste(' --------- \n This is ',self$bank_name,'. \n --------- \n'))
},
create_account = function(FirstName=NULL,SecondName=NULL,IDNo=NULL) {
FirstName = readline(prompt = "Enter FirstName: ")
# want to keep retryng until a condition is met then run your script?here you go......
library(futile.logger)
library(utils)
eod_check <- function(){
eod_file = readxl::read_excel('D:/test.xlsx')
return(eod_file$Status)
}
retry_until <- function(expr, maxErrors=5, sleep=0) {
# i used these linses of code to scrap african gendernames from the internet for one of my projects, it may not help you
library(rvest)
library(mbanalytics)
url = "https://www.momjunction.com/baby-names/african/page/%s/"
Allnames = 1:20%>%
map_df(~sprintf(url,.) %>%
read_html() %>% html_table(fill = T) %>% as.data.frame() %>%
select(NAMES,GENDER) %>% filter(!grepl("googletag.cmd.",NAMES),GENDER != "Unisex") %>%
mutate(GENDER = ifelse(GENDER == "Boy","M","F"), NAMES = tolower(NAMES))) %>%
rename_all(tolower)