Skip to content

Instantly share code, notes, and snippets.

@blzzua
blzzua / http-parse-bashim.py
Created March 20, 2017 14:47
html parsing bash.im citate
#!/usr/bin/python3
# -*- encoding: utf8 -*-
from html.parser import HTMLParser
from html import unescape
import pycurl
from io import BytesIO
class Citate():
def __init__(self):
IP=$1
# проверить является ли IP - адресом/хостом с портом. [127.0.0.1]:21212
ISPORT=$(expr match "$IP" '\[.*]\:[0-9]\{1,5\}')
if [[ ISPORT -gt 0 ]];
then
echo "$IP не является ip-адресом. поиск и замена таких адресов пока не реализован"
exit 0
fi
#!/bin/bash
echo "Авдеевка Донецкая
Александрия Кировоградская
Александровск Луганская
Алмазная Луганская
Алупка Крым
Алушта Крым
Алчевск Луганская
Ананьев Одесская
@blzzua
blzzua / sp_spaceused_as_select.sql
Created September 30, 2019 15:50
sp_spaceused as select from dmv
/*
* Query that simulates running sp_spaceused on every applicable object in a database and gathering it all into a single result set
* This set-based approach is more efficient then actually doing that.
* The logic is derived strait from the source of sp_spaceused, so the numerical values should be a 1-to-1 match.
* Three changes have been made to the result set:
* (1) The object's schema and type are included.
* (2) Actual numbers are used in the result instead of strings with ' KB' appended to the end.
* (3) The reserved, data, index_size, and unused columns are renamed with a postfix of '_kb'.
* Compatibility: 2005+
* Released by Greg Drake on 2013-06-03
#
# rison for python (parser only so far)
# see http://mjtemplate.org/examples/rison.html for more info
#
######################################################################
#
# the rison parser is based on javascript openlaszlo-json:
# Author: Oliver Steele
@blzzua
blzzua / graph_ellipse.py
Last active November 28, 2019 14:24
реализация эллипса на базе библиотеки graph
#!/usr/bin/python
# -*- coding: utf-8 -*-
from graph import *
from math import sin, cos, pi
def ellipse( x1, y1, x2, y2, vertex_count = 36 ):
"""
Рисует эллипс, вписанный в прямоугольник x1,y1 x x2,y2
"""
(x1, x2) = (min(x1, x2), max(x1, x2))
@blzzua
blzzua / graph_star.py
Created November 28, 2019 16:02
реализация "звезды" на библиотеке graph
from graph import *
from math import sin, cos, atan, sqrt, pi
def cart2pol(x, y):
r = sqrt(x**2 + y**2)
phi = atan(y, x)
return (r, phi)
@blzzua
blzzua / bspline.py
Last active November 30, 2019 18:55
bspline with out numpy
#import numpy as np
# cv = list of 2d control vertices
# n = number of samples (default: 100)
# d = curve degree (default: cubic = 3)
# closed = is the curve closed (periodic) or open? (default: open)
def bspline(cv, n=100, d=3, closed=False):
# Create a range of u values
count = len(cv)
knots = None
u = None
import turtle
import math
from math import cos, sin, pi
# turtle.delay(50)
def cart2pol(x, y):
r = sqrt(x**2 + y**2)
phi = atan(y, x)
return (r, phi)
@blzzua
blzzua / gist:329b8bfce0af8a038242ff01b3d25a48
Created June 18, 2020 06:31 — forked from cdown/gist:1163649
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf "$c" ;;