Skip to content

Instantly share code, notes, and snippets.

import requests
from operator import itemgetter
url = 'http://smt.qa.mail.ru/stands.json'
r = requests.get(url)
result = r.json()
for stand in result:
@vasmedvedev
vasmedvedev / slideshows.json
Created May 11, 2017 10:30
JSON with slides
{"count": 4, "slideshows": [{"created_ts": 1479458066, "user_id": 7, "title": "Fifth slideshow", "site_id": 6, "slides": [{"is_animated_gif": false, "description": "", "manual_image_crops": {}, "title": "", "media": "https://s3.amazonaws.com/dev-assets.rbl.ms/medvedev/495/980x.jpg", "media980x": "https://s3.amazonaws.com/dev-assets.rbl.ms/medvedev/495/980x.jpg", "media600x": "https://s3.amazonaws.com/dev-assets.rbl.ms/medvedev/495/600x.jpg", "video_shortcode": null, "tracking_code": "", "credit": "", "media210x": "https://s3.amazonaws.com/dev-assets.rbl.ms/medvedev/495/210x.jpg", "image_in_library": false, "video_embed": null, "media_type": 1, "media300x": "https://s3.amazonaws.com/dev-assets.rbl.ms/medvedev/495/300x.jpg", "id": "gkFSlR", "media35x35": "https://s3.amazonaws.com/dev-assets.rbl.ms/medvedev/495/35x35.jpg", "thumb": "https://s3.amazonaws.com/dev-assets.rbl.ms/medvedev/495/35x35.jpg"}, {"is_animated_gif": false, "description": "", "manual_image_crops": {}, "title": "", "media": "https://s3.amazona
@vasmedvedev
vasmedvedev / article.md
Created January 18, 2017 21:47
Article markdown

Russia is threatening the "liberal international order": Biden went after Putin directly, and said he's using "every tool" in his power to whittle away at Europe and undermine Western democracies. Biden also warned that he expects Russia to meddle in the many European elections being held later this year. \n\n\n**"The top 1% is not carrying their weight"****: Steps must be taken to close the rift between those "racing ahead at the top" and those "struggling to hang on in the middle." \n\nBeware emerging demagogues and autocrats: They're seeking to capitalize on people's insecurities. Biden discussed the rising popular movements across the world, and said they demonstrate a dangerous willingness to revert to political small-mindedness. "In this case, using Islamophobic, anti-Semitic, or xenophobic rhetoric to stoke fear, sow division, and advance their own narrow agendas" offers only a false sense of security. \n\nDavos tell us how you really feel:** a nice detail from the pool report by Steve

@vasmedvedev
vasmedvedev / stats.py
Created October 28, 2016 05:17
Dodo api 2
from stats.abstract_factory import StatsFactory
from community.models import Site
from roar.posts.models import Post
site = Site.objects.get_by_id(376394)
stats_api = StatsFactory().make_real_instance().make_dynamic_content_api()
popular_articles_ids = stats_api.get_site_top_post_id_list_for_last_hour(site.id, limit=5)
print popular_articles_ids
# [2063523886L, 1442440440L, 2066492082L, 2066734997L, 2066743186L]
@vasmedvedev
vasmedvedev / scrapy.py
Created October 16, 2016 17:28
Scrape fragment
import scrapy
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.contrib.linkextractors import LinkExtractor
from scrapper.items import ModelItem, DjangoCarModel, DjangoCarBrand
class CarModelSpider(CrawlSpider):
name = 'car_models'
allowed_domains = ['drom.ru']
start_urls = ['http://auto.drom.ru']
@vasmedvedev
vasmedvedev / seeker_player.html
Last active October 10, 2016 08:30
Seeker rev3 video
<div class="article-media">
<script src="https://mssl.fwmrm.net/p/ddn_live/AdManager.js"></script>
<video id="rev3-player" class="mejs-rev3" width="100%" height="auto"></video>
<script type="text/javascript">
adConfig.revision3_video_id = "78879";
var r3player, streamSense;
require(['jquery'], function($) {
var sourceDomain = "https://statics.revision3.com/ui/sk/";
var url = "http://api.seekernetwork.com/api/getNetworkMasher.json?network=seekernetwork.com&api_key=dfca5770763ffa67f79787533ec16b9ad75c72e5";
@vasmedvedev
vasmedvedev / soup.py
Created August 31, 2016 11:11
Soup example
def insert_mid_related_articles(content, urls):
soup = bs4.BeautifulSoup(content, 'html.parser')
paragraphs = soup('p')
words_count = 0
if len(paragraphs) > 1:
for p in paragraphs:
words = filter(bool, re.split('\W+', p.string))
words_count += len(words)
if words_count > 300:
middle = len(paragraphs) / 2
@vasmedvedev
vasmedvedev / mb.py
Last active July 28, 2016 09:51
Module mb
from ma import Second
class B(Second):
def __init__(self, _):
pass
@staticmethod
def fnc(a, b):
@vasmedvedev
vasmedvedev / ma.py
Created July 27, 2016 10:31
Module ma
class Parent(object):
pass
class MyError(Exception):
pass
class isSecondField(object):
def __init__(self, value):
self.value = value
@vasmedvedev
vasmedvedev / main.py
Created October 4, 2015 19:38
HabraProxy
import bs4
import os
import requests
import re
import SimpleHTTPServer
import SocketServer
from cStringIO import StringIO
PORT = 8000