Skip to content

Instantly share code, notes, and snippets.

View ortsed's full-sized avatar

Llewellyn Jones ortsed

View GitHub Profile
@ortsed
ortsed / make_deal.py
Last active February 7, 2019 15:46
Simulate Monty Hall Problem
from random import randint
i = 0
# count of wins without switching choice, with switching
without_switching = 0
with_switching = 0
iterations = 100000
while i <iterations:
@ortsed
ortsed / get_urls.py
Created November 8, 2017 21:55
Get all versions from archive.org
# 1. Change the URL to the url of the site to be archived
# 2. run this script and pipe to an output text file FILENAME
# 3. Download the URLs via wget -i FILENAME
import json
from urllib.parse import urlencode, quote_plus
URL = "https://www.url.com"
@ortsed
ortsed / pdf_to_word.py
Created October 30, 2015 20:45
PDF to Word Converter
import os
import subprocess
for top, dirs, files in os.walk('/my/pdf/folder'):
for filename in files:
if filename.endswith('.pdf'):
abspath = os.path.join(top, filename)
subprocess.call('lowriter --invisible --convert-to doc "{}"'
.format(abspath), shell=True)
@ortsed
ortsed / gist:b3e310f49b15129b8d2f
Created October 18, 2015 20:43
MySQL to Create Table of Market Holidays
CREATE TABLE calendar_table (
dt DATE NOT NULL PRIMARY KEY,
y SMALLINT NULL,
q tinyint NULL,
m tinyint NULL,
d tinyint NULL,
dw tinyint NULL,
monthName VARCHAR(9) NULL,
dayName VARCHAR(9) NULL,
w tinyint NULL,
@ortsed
ortsed / gist:9818cf89b7fc3cec5f39
Created October 2, 2015 19:36
Django setup script
#installation
yum update
yum install gcc mysql-devel python-devel mariadb-server mysql MySQL-python git
yum install epel-release
yum install nginx
easy_install Django pip uwsgi
export CLICOLOR=1
function settitle() { echo -ne "\033]0;$@\007";}
alias untar=’tar xvzf’
alias push='git push origin'
alias pull='git pull origin'
alias restart='sudo /usr/local/apache2/bin/apachectl restart'
alias stop='sudo /usr/local/apache2/bin/apachectl stop'
alias pkill='~/pkill.sh'
#!/bin/sh
ADDRESS='127.0.0.1'
PYTHON="/opt/django/bin/python"
GUNICORN="/opt/django/bin/gunicorn_django"
PROJECTLOC="/opt/django/project"
MANAGELOC="$PROJECTLOC/manage.py"
DEFAULT_ARGS="--workers=3 --daemon --bind=$ADDRESS:"
BASE_CMD="$GUNICORN $DEFAULT_ARGS"