Skip to content

Instantly share code, notes, and snippets.

View M0nica's full-sized avatar

Monica Powell M0nica

View GitHub Profile
@M0nica
M0nica / calc_test.py
Created February 10, 2017 12:45
This code outputs "The percent change between 500 and 575 is 0%" on Heroku but "The percent change between 500 and 575 is 15%" locally
original_number = int(request.form['original'])
new_number = int(request.form['new'])
result = ((new_number - original_number)/int(original_number)) * 100
response = "The percent change between " + str(original_number) + " and " + str(new_number) + " is " + str("%.0f%%" % result)
@M0nica
M0nica / .gitattributes
Created September 4, 2017 23:09
Remove vendor files from GitHub's classification of the repositories language
static/* linguist-vendored
@M0nica
M0nica / config.py
Created September 4, 2017 23:12
An example config.py to hide API keys in python.
# .gitignore should include reference to config.py
api_key = "YOUR_KEY"
api_secret = "YOUR_SECRET"
access_token = "YOUR_ACCESS_TOKEN"
token_secret = "YOUR_TOKEN_SECRET"
@M0nica
M0nica / main_script.py
Created September 4, 2017 23:13
An example script to pass in API keys/hidden variables from config.py
import config
from twython import Twython, TwythonError
# create a Twython object by passing the necessary secret passwords
twitter = Twython(config.api_key, config.api_secret, config.access_token, config.token_secret)
@M0nica
M0nica / .gitignore
Created September 4, 2017 23:14
Example git ignore file for Python projects
config.py
__pycache__
.ipynb_checkpoints
@M0nica
M0nica / author_bio.html
Last active October 7, 2017 15:27
Example template for including author data in Jekyll
<hr>
<span>
<div>
# include author image if there is an author image
{% if author.image %}
<img src="{{author.image}}" class="author-img">
{% endif %}
<div>
<h3> {{author.name}} &nbsp;
# include link to author's twitter if they have provided a twitter account
@M0nica
M0nica / addToFreeCodeCampList.py
Last active December 24, 2017 14:48
A python script to search Twitter for #FreeCodeCamp and add recent Tweeters to a Twitter list.
import config
from twython import Twython, TwythonError
# create a Twython object by passing the necessary secret passwords
twitter = Twython(config.api_key, config.api_secret, config.access_token, config.token_secret)
# return tweets containing #FreeCodeCamp
response = twitter.search(q='"#FreeCodeCamp" -filter:retweets', result_type="recent", count=100)
import { LocalDate, ChronoUnit } from "js-joda";
export function getToday() {
return LocalDate.now();
}
export function getNextYear(date) {
return date.year() + 1;
}
// @flow
import { LocalDate, ChronoUnit } from "js-joda";
export function getToday(): LocalDate {
return LocalDate.now();
}
export function getNextYear(date: LocalDate): number {
return date.year() + 1;
@M0nica
M0nica / prepush.sample
Last active February 28, 2019 04:52
A bash script that can be used in prepush Git hook to warn when pushing changes to master or an otherwise protected branch
protected_branch='master'
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
# define bash colors to display
yellow='\033[0;33m'
red='\033[0;31m'
green='\033[0;32m'
no_color='\033[0m'