This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import Counter | |
class ArticleHashtags: | |
def __init__(self, text): | |
self.text = text | |
def get_most_common_words(self, n=5, text_min_lenth=5): | |
""" | |
Returns 5 most common words in string. | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
cat ~/.ssh/id_rsa.pub | ssh username@hostname "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Django with Plotly - example</title> | |
</head> | |
<body> | |
{% if view.generate_plot %} | |
<div style="width: 100%; height: 100%;"> | |
{{ view.generate_plot|safe }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db.models.expressions import RawSQL | |
from apps.core.models import MyModel | |
sql_query = """SELECT * FROM my_table;""" | |
raw_sql = RawSQL( | |
sql=sql_query, | |
params=[1] | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import logging | |
from random import randint | |
from time import sleep | |
from django.db.models import F | |
from requests import RequestException | |
from requests import get | |
from user_agent import generate_user_agent | |
from proxy.models import Proxy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from selenium import webdriver | |
from selenium.webdriver import ActionChains | |
from selenium.webdriver.common.by import By | |
from selenium.webdriver.support import expected_conditions as ec | |
from selenium.webdriver.support.ui import WebDriverWait | |
driver = webdriver.Chrome() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def flatten(x): | |
""" | |
Merges flatten lists into the one. | |
""" | |
return [a for i in x for a in flatten(i)] if isinstance(x, collections.Iterable) else [x] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker stop $(docker ps -a -q) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Remove all the dangling images | |
DANGLING_IMAGES=$(docker images -qf "dangling=true") | |
if [[ -n $DANGLING_IMAGES ]]; then | |
docker rmi "$DANGLING_IMAGES" | |
fi | |
# Get all the images currently in use | |
USED_IMAGES=($( \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from urllib2 import Request, URLError, urlopen, build_opener, ProxyHandler, install_opener | |
def request_with_proxy(): | |
proxy = ProxyHandler( |