Skip to content

Instantly share code, notes, and snippets.

View GLMeece's full-sized avatar

Greg Meece GLMeece

View GitHub Profile
"""Nice Title Case Function plus quick demo"""
def nice_title_case(str_in: str) -> str:
"""Converts a string to Title Case, with conventional exceptions which
need not be capitalized if they are not the first word in the title.
Reference: https://en.wikipedia.org/wiki/Title_case
*Note*: Prepositional rules are not strictly enforced
@GLMeece
GLMeece / http_bad_codes_dict.py
Created March 15, 2019 15:46
HTTP Bad Return Codes (as Python Dictionary)
http_bad_codes = {
"400": "Bad Request",
"401": "Unauthorized",
"402": "Payment Required",
"403": "Forbidden",
"404": "Not Found",
"405": "Method Not Allowed",
"406": "Not Acceptable",
"407": "Proxy Authentication Required",
"408": "Request Timeout",
@GLMeece
GLMeece / pandoc_markdown_to_word.md
Last active October 2, 2018 18:10
Using PanDoc to Convert Word to Markdown
pandoc -f docx -t markdown -o my_example_output.md my_example_input.docx
@GLMeece
GLMeece / Python_Virtual_Environments.md
Last active November 25, 2019 10:25
Setting up a Virtual Environment for Python using VirtualEnvWrapper

Virtual Environments

  1. Before beginning, you should have a version of pip installed. If you don't, it is recommended you install it universally via the Terminal: sudo easy_install pip
  2. Once you do, install virtualenvwrapper: sudo pip install virtualenvwrapper. More information can be found in Read the Docs
  3. Change into the directory where your new project is; e.g., cd ~/Documents/Repos/my_new_project
  4. Create your new environment in this directory, automatically giving it the name of the current directory: thisdir=${PWD##*/};mkvirtualenv -a . -r requirements.txt $thisdir

Using Your Virtual Environment

  • To make sure you remember what your virtual environment is named (and, indeed - all you have created), execute lsvirtualenv which lists all virtual environments.
@GLMeece
GLMeece / Sphinx_Setup_for_autodoc.md
Last active January 31, 2025 03:04
Setting up Sphinx for generating documentation from DocStrings, leveraging the Napoleon extension.

Sphinx Setup for autodoc

Sphinx is a documentation generator that is the de facto standard for Python projects. The official documentation can be a bit daunting as it includes so many options, it's hard to know where to start.

Note: This Gist was updated on 04/04/2019 to accomodate a newer version of Sphinx, as well as Python 3.7. YMMV!

This document is written with the following presuppositions:

Testing reST Code Blocks

Code Block (Python):

jnk_instance = "http://jenkins.jarvis.cylancecorp.com:8080/"
jnk_user = 'myusername'
jnk_pass = 'mypassword'
my_test_run = JenkinsJobTestRunRetrieval(jnk_instance, jnk_user, jnk_pass)
@GLMeece
GLMeece / meta-tags.md
Last active December 24, 2020 04:37 — forked from kevinSuttle/meta-tags.md
List of Usable HTML Meta and Link Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta charset='UTF-8'>
<meta name='keywords' content='your, tags'>
<meta name='description' content='150 words'>
<meta name='subject' content='your website's subject'>
<meta name='copyright' content='company name'>
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Determine whether integer is a prime or not.
- *Module*: is_prime
- *Platform*: Unix, Windows
- *Author*: [mailto:[email protected]?subject=About is_prime.py|Greg Meece]
"""
@GLMeece
GLMeece / open_browser_examples.robot
Last active September 27, 2019 08:55
Open Browser Examples
# Starting with a generic "Open Browser to Page" keyword, following that are examples for:
# Google Chrome
# PhantomJS
#
# Assumed global or suite variables:
# ${browser} - the browser you want to use in testing
# ${delay} - the "speed" that Selenium verbs execute at
# ${user_agent} - User Agent string like: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36
#
# Note: The documentation is written with the libdoc utility in mind. See:
@GLMeece
GLMeece / how_to_execute_robot_framework_tests.md
Last active October 3, 2022 10:00
How to Run Robot Framework Tests

About

This is a quick "how to run" if you already have everything Robot Framework-related installed. This Gist might be especially handy for those you either just starting out, or if you've inherited a code-base from someone else.

The following assumes you have a terminal (CMD or PowerShell on Windows, Terminal on Mac or Linux) and aren't afraid to use it.

Testing ALL THE THINGS

Test All the Things

  1. cd into the root directory of the Robot Framework files and test cases; we'll assume all test cases are somewhere within a directory named test_cases.