Skip to content

Instantly share code, notes, and snippets.

View ro6ley's full-sized avatar
🐼
...typing

Robley Gori ro6ley

🐼
...typing
View GitHub Profile
@ro6ley
ro6ley / mongo_db_script.py
Created January 28, 2020 13:59
A simple script to showcase PyMongo usage in vanilla Python.
from pymongo import MongoClient
# create a MongoDB client
client = MongoClient('localhost', 27017)
series_db = client['SeriesDB']
series_collection = series_db['series']
def insert_document(collection, data):
@ro6ley
ro6ley / simple_calculator.py
Last active July 6, 2022 13:44
Unit Testing in Python using UnitTest Framework
#!/usr/bin/env python3
class SimpleCalculator:
def sum(self, a, b):
""" Function to add two integers """
if isinstance(a, int) and isinstance(b, int):
return a + b
else:
return "ERROR"
@ro6ley
ro6ley / alphabetic_order.py
Created November 18, 2018 16:59
Function to check whether the letters in a word are in the Alphabetic order
def check_order(str):
"""
This function checks whether the letters in an alphabet
are sorted alphabetically and returns True.
Otherwise it returns False
"""
if ''.join(sorted(list(str))) == str:
return True
else:
return False
@ro6ley
ro6ley / .vimrc
Last active June 5, 2018 05:59
My VIM configuration
"Vundle setup instructions - https://github.com/VundleVim/Vundle.vim
"Pathogen setup instructions - https://github.com/tpope/vim-pathogen
":PluginInstall
execute pathogen#infect()
syntax on
filetype plugin indent on
set expandtab
set tabstop=4
@ro6ley
ro6ley / nairobley.zsh-theme
Last active August 11, 2018 12:17
A ZSH theme that is a combination of Steef and Robby Russel
# local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
# PROMPT='${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
function virtualenv_info {
[ $VIRTUAL_ENV ] &&
echo '('%F{blue}`basename $VIRTUAL_ENV`%f') '
}
#use extended color palette if available
if [[ $terminfo[colors] -ge 256 ]]; then
alias gs='git status '
alias ga='git add '
alias gb='git branch '
alias gco='git checkout '
alias gcob='git checkout -b '
alias gcot='git checkout -t '
alias gc='git commit '
alias gl='git pull '
alias gf='git fetch '
alias gp='git push '
@ro6ley
ro6ley / CodeChallenge.py
Created March 6, 2017 11:27
My solution to the challenges sent via email
def sum_even(a):
sum = 0
for num in a:
if num%2 == 0:
sum+=num
return sum
def super_sum(a):
sum = 0
for num in a: