Skip to content

Instantly share code, notes, and snippets.

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

impshum

:octocat:
Loading...
View GitHub Profile
@impshum
impshum / filler.py
Created August 26, 2018 13:23
Create 1MB files forever
from string import digits, ascii_uppercase
from random import choice
c = 0
while 1:
c += 1
with open(str(c), 'w+') as f:
f.write(''.join(choice('ascii_uppercase + digits') for x in range(999999)))
from nltk.tokenize import word_tokenize
from nltk.corpus import stopwords
from collections import OrderedDict
import string
import praw
import re
import matplotlib.pyplot as plt
client_id = 'XXXX'
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'
@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
@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 / 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)
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 / 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)
@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'