Skip to content

Instantly share code, notes, and snippets.

import requests
from bs4 import BeautifulSoup
import shutil
DIR = '/home/dani/bin/dota_2_items/'
html = requests.get('https://dota2.gamepedia.com/Items').text
s = BeautifulSoup(html, 'html.parser')
mark = s.find('span', id="Items")
#!/bin/env python
"""
"option definitions" and "time definitions could also have been placed in extra files and imported.
"""
#-----------------------
#- Option Definitions: -
#-----------------------
options = {
@fuzzy-focus
fuzzy-focus / API-client.py
Created January 17, 2017 08:20
Hug Put Demo
import requests
print(requests.put('http://localhost:8000/test',data={'txt':'Hello World'}).json())
# prints "success"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
## First ##########################################
mystery = iter('')
# challenge code
def print_stuff(stuff):
if stuff:
print "Printing some stuff"
for x in stuff:
print x
else:
print "Nothing to print"
import itertools
import collections
#utility functions
def calc_dist(dice_list,fun):
cntr = {i:0 for i in range(2,13)}
cntr.update(collections.Counter(map(fun, dice_list)))
if len(cntr) != 11: # discard if sums outside of range(2,13) are generated
return ['== WRONG == ']*11
return ['{: >3} : {: >5.2f}%'.format(k,100*v/len(dice_list)) for k,v in cntr.items()]