Skip to content

Instantly share code, notes, and snippets.

@Vostbur
Vostbur / cisco_mngt.py
Created January 17, 2020 16:45
Connect to Cisco with telnet and run any command
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 17 2020
@author: [email protected]
Connect to Cisco with telnet and run any command
(show startup-config by default).
login, password and enable password is same for all devices.
Ip addresses reads from json config file.
@Vostbur
Vostbur / simple_todo_with_db.py
Created February 22, 2020 08:41
Simple TODO with sqlite
# -*- coding: utf-8 -*-
import re
import sqlite3
import os
db_filename = "dbase.db"
db_exists = os.path.exists(db_filename)
query_schema = "create table if not exists tasks(\
@Vostbur
Vostbur / app.py
Created February 22, 2020 08:47
Example WSGI framework
"""
Example application.
httpsrv - wsgi compatible class.
Debug internal server - wsgiref.
"""
from httpsrv import Application
app = Application()
@Vostbur
Vostbur / wsgi_example.py
Created February 22, 2020 08:59
Small WSGI server
# -*- coding: utf-8 -*-
'''
Small wsgiref based web server. Takes a path to serve from and an
optional port number (defaults to 8000), then tries to serve files.
Mime types are guessed from the file names, 404 errors are raised
if the file is not found. Used for the make serve target in Doc.
'''
import sys
import os
import mimetypes
@Vostbur
Vostbur / images_scraper.py
Created April 1, 2020 09:42
Multithreading image scraper from web pages
# viewed in https://www.thepythoncode.com/article/download-web-page-images-python
# for example (be attention 18+ :) ): python image-scraper.py -o boobs -p 1000 http://oboobs.ru
import requests
import os
from tqdm import tqdm
from bs4 import BeautifulSoup as bs
from urllib.parse import urljoin, urlparse
from concurrent.futures import ThreadPoolExecutor
from itertools import repeat
@Vostbur
Vostbur / index.html
Created April 17, 2020 11:52
Web audio recorder
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>Voice comments</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
@Vostbur
Vostbur / main.go
Created May 5, 2020 08:17
Comparing binary search on Go and Python
package main
import (
"errors"
"fmt"
"log"
)
func binsearch(data []int, item int) (int, error) {
start, end := 0, len(data)-1
@Vostbur
Vostbur / main.go
Created May 5, 2020 19:02
Selection sort. Go vs Python
package main
import "fmt"
func selection_sort(data *[]int) {
l := len(*data)
for i := 0; i < l; i++ {
min_element := i
for j := i + 1; j < l; j++ {
if (*data)[min_element] > (*data)[j] {
@Vostbur
Vostbur / main.go
Last active May 7, 2020 15:13
Calculate max square with the euclidean algorithm. Go vs Python
package main
import "fmt"
func eucl_alg(width int, length int) int {
var min_side int
if width < length {
min_side = width
} else {
min_side = length
@Vostbur
Vostbur / main.go
Created May 7, 2020 15:12
Quick sort. Go vs Python
package main
import "fmt"
func quick_sort(arr []int) []int {
if len(arr) < 2 {
return arr
}
pivot := arr[0]