Skip to content

Instantly share code, notes, and snippets.

View AnthonyBloomer's full-sized avatar

Anthony Bloomer AnthonyBloomer

View GitHub Profile
@AnthonyBloomer
AnthonyBloomer / convert.py
Created January 6, 2016 03:14
Convert a decimal to a given base and then back to it's decimal representation.
# convert a decimal to a given base
def d2b(dec, base):
stack = []
result = ''
while dec > 0:
rem = dec % base
dec = dec / base
stack.append(rem)
while stack:
result += str(stack.pop())
@AnthonyBloomer
AnthonyBloomer / collatz.py
Last active August 20, 2016 17:33
Collatz conjecture
import sys
# Take any positive integer n.
# If n is even, divide it by 2 to get n / 2.
# If n is odd, multiply it by 3 and add 1 to obtain 3n + 1.
# The conjecture is that no matter what number you start with, you will always eventually reach 1.
def collatz(n):
if n % 2 == 0:
import sys
import requests
import random
import subprocess
if len(sys.argv) == 2:
genre = sys.argv[1]
request = requests.get('https://yts.ag/api/v2/list_movies.json?genre=%s&minimum_rating=8&limit=50' % genre)
@AnthonyBloomer
AnthonyBloomer / env.sh
Created February 5, 2017 01:37
Using Python 3 in virtualenv
virtualenv -p python3 envname
from slideshare import Slideshare
from pymongo import MongoClient
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('topic')
args = parser.parse_args()
client = MongoClient('mongodb://localhost:27017/')
db = client.slideshare
@AnthonyBloomer
AnthonyBloomer / flickr.py
Created April 11, 2017 16:09
Download photosets on Flickr.
import requests
import urllib
import pprint
import os
import argparse
import sys
def main(photoset):
try:
wget --page-requisites https://www.example.com
@AnthonyBloomer
AnthonyBloomer / git2dropbox.py
Created June 12, 2017 20:30
Backup public Github repos to a Dropbox account.
from github import Github
import dropbox
import os
import config
IGNORED_FILES = ['desktop.ini', 'thumbs.db', '.ds_store', 'icon\r', '.dropbox', '.dropbox.attr']
dc = dropbox.client.DropboxClient(config.dropbox_access_token)
g = Github(config.github_username, config.github_password)
git fetch --all
git merge origin/master
git push
require 'colorize'
progression = 0
jackpot = 16
milestones = {
4 => '€500',
8 => '€2,500',
12 => '€100,000',
16 => '€250,000'