Skip to content

Instantly share code, notes, and snippets.

💭
trying to quit vim

Ilya Lebedev Melevir

💭
trying to quit vim
View GitHub Profile
@Melevir
Melevir / sqrt_speed_test.py
Last active Sep 9, 2016
Тест того, что быстрее: sqrt или **
View sqrt_speed_test.py
import math
from datetime import timedelta, datetime
def get_time(callable_stuff, tries=10):
deltas = []
for _ in range(tries):
now = datetime.now()
callable_stuff()
deltas.append(datetime.now() - now)
View linio_search_parse.py
import requests
from bs4 import BeautifulSoup
def get_product_info_from_website(sku):
host = 'https://www.linio.com.mx'
search_page_text = requests.get('%s/search' % host, params={'q': sku}).text
page = BeautifulSoup(search_page_text)
url = page.find('div', {'class': 'catalog-product-title'})
if not url:
View furby_qr.py
import os
import string
import itertools
from datetime import datetime
import elaphe
def create_dirs():
if not os.path.exists('data'):
View gist:d615635444254a45f7f7
SELECT
name,
count(*) as msg_count
FROM users
JOIN messages on users.uid = messages.uid
GROUP BY users.uid;
View gist:284d03d7606364787c69
def zip_long(keys, values):
""" Версия zip, которая не удаляет лишние ключи, а оставляет их со значениями None"""
values += [None] * (len(keys) - len(values))
return dict(zip(keys, values))
def test_zip_long():
""" Тестирование для бедных.
При запуске выполнит тестирование функции zip_long и вернет True если тесты прошли
(иначе выкинет AssetrionError).
@Melevir
Melevir / gist:6689056
Created Sep 24, 2013
GitHub Search API example with hammock
View gist:6689056
from hammock import Hammock as Github
github = Github('https://api.github.com')
headers = {'Accept': 'application/vnd.github.preview'}
resp = github.search.repositories.GET(params={'q': 'language:python', 'sort': 'stars', 'per_page': 10, 'page': 1}, headers=headers)
res = resp.json()
print res['items'][0]['full_name']
print len(res['items'])
You can’t perform that action at this time.