Skip to content

Instantly share code, notes, and snippets.

View NetBUG's full-sized avatar

Oleg NetBUG

View GitHub Profile
#!/usr/bin/python3
import requests
from bs4 import BeautifulSoup
def clean(url):
r = requests.get(url)
html = r.text
soup = BeautifulSoup(html, "lxml")
for script in soup(["script", "style"]):
@NetBUG
NetBUG / mediaplayer.qml
Created October 24, 2016 13:52
raw /usr/share/jolla-mediaplayer/mediaplayer.qml
// -*- qml -*-
import QtQuick 2.0
import Sailfish.Silica 1.0
import Sailfish.Media 1.0
import com.jolla.mediaplayer 1.0
import org.nemomobile.thumbnailer 1.0
import org.nemomobile.dbus 2.0
import "scripts/AlbumArtFinder.js" as AlbumArtFinder
import "cover"
@NetBUG
NetBUG / sarimax_sample.py
Created November 27, 2016 23:18
Minimaliztic SARIMAX usage demo
import sys
from datetime import datetime
import statsmodels.api as sm
import statsmodels.tsa.stattools as st
import pandas as pd
import json
import pytz
import matplotlib.pyplot as plt
import numpy as np
import math
@NetBUG
NetBUG / candle_8266.ino
Created March 6, 2017 15:44
Candlelight on ESP8266
/*
IoT Manager mqtt device client https://play.google.com/store/apps/details?id=ru.esp8266.iotmanager
Based on Basic MQTT example with Authentication
PubSubClient library v 1.91.1 https://github.com/Imroy/pubsubclient
- connects to an MQTT server, providing userdescr and password
- publishes config to the topic "/IoTmanager/config/deviceID/"
- subscribes to the topic "/IoTmanager/hello" ("hello" messages from mobile device)
Tested with Arduino IDE 1.6.6 + ESP8266 Community Edition v 2.0.0-stable and PubSubClient library v 1.91.1 https://github.com/Imroy/pubsubclient
ESP8266 Community Edition v 2.0.0-stable have some HTTPS issues. Push notification temporary disabled.
@NetBUG
NetBUG / DHT11.ino
Last active March 21, 2017 12:39
Подключение сенсоров к Arduino
// Устанавливаем библиотеку: https://github.com/amperka/dht
// подключаем библиотеку
#include <dht.h>
// создаём объект-сенсор
DHT sensor = DHT();
void setup()
{
Serial.begin(9600);
@NetBUG
NetBUG / getter.py
Last active April 12, 2017 15:00
Japanese film DB grabber
#coding=utf-8
import requests
import shutil
fn = "http://www.japanese-cinema-db.jp/Details?id="
def saveFile(path):
r = requests.get(fn + str(path), stream=True)
if r.status_code == 200:
with open(str(path) + ".htm", 'wb') as f:
@NetBUG
NetBUG / bkrsget.py
Created April 13, 2017 17:32
BKRS read for Marat
#coding=utf-8
import requests
import shutil
fn = "https://bkrs.info/changes.php?total=100&start=%d&view=words_edited"
def saveFile(path):
r = requests.get(fn % str(path), stream=True)
if r.status_code == 200:
with open(str(path) + ".htm", 'wb') as f:
@NetBUG
NetBUG / creation.sql
Created April 18, 2017 22:43
Databases for Marat
CREATE TABLE `Collection` (
`Id` int(11) NOT NULL,
`Name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `Item` (
`Id` int(11) NOT NULL,
`CollectionId` int(11) NOT NULL,
`Value` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
@NetBUG
NetBUG / find_anomalous_words.py
Created May 28, 2017 19:21
Pipeline for word analysis in Twi
import numpy as np
# @title
dict_file = 'words.txt'
users_file = 'users.txt'
users = [u for l in open(users_file).readlines()]
words = [u for l in open(words_file).readlines()]
def count_words_general(users, words):
Usage: align dictfile.txt source translate
Russian tokenization has not been implemented yet, using generic scripts...
Read total: 4860962
Reading X stop list... done.
Reading seed translation lexicon... done.
Number of entries: 29638
Loading axis...done.
Number of sentences: 31
Loading axis...done.
Number of sentences: 25