This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
virtualenv -p python3 envname |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import urllib | |
import pprint | |
import os | |
import argparse | |
import sys | |
def main(photoset): | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wget --page-requisites https://www.example.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git fetch --all | |
git merge origin/master | |
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'colorize' | |
progression = 0 | |
jackpot = 16 | |
milestones = { | |
4 => '€500', | |
8 => '€2,500', | |
12 => '€100,000', | |
16 => '€250,000' |
OlderNewer