Skip to content

Instantly share code, notes, and snippets.

View impshum's full-sized avatar
:octocat:
Loading...

impshum

:octocat:
Loading...
View GitHub Profile
# -*- coding: utf-8 -*-
import time
import sys
import os
import datetime
import speedtest
import pandas as pd
import matplotlib.pyplot as plt
from halo import Halo
#/u/GoldenSights
import json
import praw
import random
import sqlite3
import time
import traceback
'''USER CONFIGURATION'''
@impshum
impshum / commiebot.py
Created April 15, 2018 06:14
Discord bot comrade!
import sys
import praw
import discord
from halo import Halo
# Get your keys from https://www.reddit.com/prefs/apps/ and use type: script
client_id = 'xxxx'
client_secret = 'xxxx'
user_agent = 'CommieBot for Discord (by /u/impshum)'
@impshum
impshum / run.py
Created May 1, 2018 21:23
Twitter to Reddit
import time
import tweepy
import json
import sys
import praw
from halo import Halo
consumer_key = 'XXXX'
consumer_secret = 'XXXX'
access_key = 'XXXX-XXXX'
@impshum
impshum / xkcd.py
Last active June 14, 2018 09:58
Download all xkcd comics
# Create a directory called comics next to the script first
import requests
n = 933
while True:
if n == 404:
n += 1
url = 'https://xkcd.com/{}/info.0.json'.format(n)
r = requests.get(url)
from bs4 import BeautifulSoup
import requests
def lovely_soup(url):
r = requests.get(url)
html_content = r.text
soup = BeautifulSoup(html_content, 'lxml')
return soup
@impshum
impshum / count_common_words.py
Created June 15, 2018 10:40
Count common words in a txt file
import re
from collections import Counter
data = open('test.txt', 'r', encoding='utf-8').read()
words = re.findall('\w+', data.lower())
counted = Counter(words)
common = counted.most_common()
for word, score in common:
print(word, score)
@impshum
impshum / quotes.json
Created June 15, 2018 10:57
Loads of quotes
[{
"quoteText": "Genius is one percent inspiration and ninety-nine percent perspiration.",
"quoteAuthor": "Thomas Edison"
}, {
"quoteText": "You can observe a lot just by watching.",
"quoteAuthor": "Yogi Berra"
}, {
"quoteText": "A house divided against itself cannot stand.",
"quoteAuthor": "Abraham Lincoln"
}, {
@impshum
impshum / Cikloberza.py
Created August 14, 2018 11:16 — forked from skpyns/Cikloberza.py
Fetching a number of ads of used bicycles
from bs4 import BeautifulSoup
import requests
# reusable main soup function
def lovely_soup(url): # passes the url as a variable
r = requests.get(url) # get the requested url
soup = BeautifulSoup(r.text, 'lxml') # turn html content into soup
return soup
# soup helper function
from InstagramAPI import InstagramAPI
from random import randint
from time import sleep
import requests
import json
class Colour:
Green, Red, White, Yellow = '\033[92m', '\033[91m', '\033[0m', '\033[93m'