Skip to content

Instantly share code, notes, and snippets.

View filinvadim's full-sized avatar
🏠
Working from home

Vadim Filin filinvadim

🏠
Working from home
  • zodia-markets
  • Dubai
View GitHub Profile
# -*- coding: utf-8 -*-
import urllib3
import bs4
import requests
from lxml import html
import argparse
source_url = 'http://python.org'
def get_python_events_bysoup(url):
customers_balance_true = [25, 25, 25, 100]
customers_balance_false = [25, 25, 50, 100, 100]
def having_odd_money(money):
cinema_balance = 0
for banknote in money:
if banknote == 25:
cinema_balance += banknote
elif banknote == 50:
cinema_balance += banknote/2
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Джанго</title>
<link rel="stylesheet" type="text/css" href="/static/css/bootstrap.min.css">
<script src="/static/js/bootstrap.min.js"></script>
</head>
@filinvadim
filinvadim / gist:520b07e98a8a458c18a2cd5ed91044c6
Created May 22, 2017 16:44
Автоматическое обновление резюме на HH.ru
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import datetime
import time
while True:
# opening_browser
func multiparseText() string {
collectedTexts := ""
ch := make(chan string, parseThreadsNum)
defer close(ch)
for i := 0; i < parseThreadsNum; i++ {
go parseText(&ch)
}
for {
unreadData := len(ch)
if unreadData == parseThreadsNum {
@filinvadim
filinvadim / testsuite.py
Created June 19, 2017 10:08
TestSuite Example
testmodules = [
'cogapp.test_makefiles',
'cogapp.test_whiteutils',
'cogapp.test_cogapp',
]
suite = unittest.TestSuite()
for t in testmodules:
try:
@filinvadim
filinvadim / regroup.py
Created November 9, 2017 15:07
Group Travelport xml
def regroup_response(self):
"""
Groups elements of request by keys and references on keys.
NOTE that those keys and references actually have meaning of primary and foreign key
in the terms of SQL.
:param data: json like request (actually dicts with lists and strings)
:return: None
"""
keys = {}
@filinvadim
filinvadim / JSONparse.py
Created November 9, 2017 15:08
Recursive JSON parsing
def contains(self, element, list_wrap=False):
"""
Recursively seeks for requested keyword or list of keywords
:param data: json-type dict
:param element: str or list
:return: list or None
"""
collected_elements = []
def _recursively_seek(data):
@filinvadim
filinvadim / async_object.py
Created November 9, 2017 15:10
Make python object fully async
import asyncio
class _AsyncObject(object):
"""Inheriting this class allows you to define an async __init__.
So you can create objects by doing something like `await MyClass(params)`
"""
@asyncio.coroutine
def __new__(cls, *a, **kw):
@filinvadim
filinvadim / decorator.py
Last active November 9, 2017 15:17
Python decorators simple explanation
def decor(func):
def wrapped(a, b):
a = 'deco'
b = 'rated'
return func(a, b)
return wrapped # not calling yet
@decor # init decor here