Skip to content

Instantly share code, notes, and snippets.

View exemplum100's full-sized avatar
🐒
Focusing

exemplum100

🐒
Focusing
View GitHub Profile
@exemplum100
exemplum100 / minigame.py
Created July 16, 2023 07:31
Пример использования python
from tkinter import *
import shelve
import random
import time
import psycopg2
from configsql import *
class Watereat:
def __init__(self,name,energy,power):
@exemplum100
exemplum100 / parsexcel.py
Created July 16, 2023 07:31
Пример использования python c excel
import openpyxl as px
from tkinter import *
from tkinter import filedialog as fd
import os
import re
file_name='C:/Users/Default/Desktop/PyScript/PyScript/отчет.xlsx'
defrow=1
defcolumn=1
sheetnms=''
sheetl=[]
@exemplum100
exemplum100 / telebot_py.py
Created July 16, 2023 07:31
Пример использования Python с Telegram
import config
import telebot
import re
import time
import datetime
from threading import Thread
import schedule
from time import sleep
import requests
import random
@exemplum100
exemplum100 / generatenames.sql
Created July 16, 2023 07:31
Случайная генерация имен для наполнения БД
USE [sqlnames]
GO
/****** Object: StoredProcedure [dbo].[sp_generatenames] ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_generatenames]
@genvalue INT
AS
@exemplum100
exemplum100 / example.sql
Created July 16, 2023 07:32
Примеры сложных запросов
--Фильтрация данных под шаблон
WITH cte as (
SELECT e.CREATED_ON,e.DATE_,e.AXIS_1,'D_1' as AXIS_2,
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(AXIS_3,'"',''),'дата продажи',''),'.',''),' ',''),',',''),'АББ','АБВ') as AXIS_3,
e.AXIS_4, 'Имя компании' as AXIS_5, e.AXIS_6, REPLACE(SUBSTRING(AXIS_3,0,CHARINDEX(',',AXIS_3)),'АББ','АБВ') as AXIS_7
FROM etls as e WHERE
e.AXIS_6 != 'TEST' or e.AXIS_6 is NULL
UNION ALL
SELECT e.CREATED_ON,e.DATE_,e.AXIS_1,'D_2' as AXIS_2,
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(AXIS_3,'"',''),'дата продажи',''),'.',''),' ',''),',',''),'АББ','АБВ') as AXIS_3,
@exemplum100
exemplum100 / adhoc1.sql
Created July 16, 2023 07:32
Пример использования курсора для поиска аномалий в системе для выявления инцидента
CREATE TABLE #rezults
(cobj BIGINT,
times DATETIME,
counts INT)
DECLARE @xg1 DATETIME2,
@xg2 INT,
@xg3 BIGINT,
@mess VARCHAR(300),
@logr DATETIME2
SET @xg2=0
@exemplum100
exemplum100 / geography_point.sql
Created July 16, 2023 07:32
Использование типа GEOGRAPHY для adhoc отчета
DECLARE geo_kursor CURSOR LOCAL FOR
SELECT k.pin,k.lat,k.long,k.geo,k.reciv FROM #koors3 AS k
ORDER BY k.reciv
OPEN geo_kursor
FETCH NEXT FROM geo_kursor
INTO @pinfirst,@latg,@longg,@geocurs,@receiv ---LOOK
WHILE @@FETCH_STATUS=0
BEGIN
SET @userloc = geography::Point(@latg, @longg, 4326).STBuffer(@km)
SET @checkgeo1 = (SELECT TOP (1) t.checkgeo FROM #t2 AS t WHERE t.checkpin=@pinfirst ORDER BY t.receivedm DESC )
@exemplum100
exemplum100 / postgist.py
Created July 16, 2023 07:32
Gists update
import requests
import json
GITHUB_API="https://api.github.com"
API_TOKEN = config.token
#
a = []
x=open(config.discr, 'r')
@exemplum100
exemplum100 / outl.py
Last active April 5, 2024 16:53
Py+Outlook
import os
import win32com.client as win32
olApp = win32.Dispatch('Outlook.Application')
olNS = olApp.GetNameSpace('MAPI') # NameSpaces need for attchm
mailItem = olApp.CreateItem(0)
mailItem.Subject = 'Dummy Email2'
mailItem.BodyFormat = 1
mailItem.Body = "Hello World"
@exemplum100
exemplum100 / zipdir.py
Created July 16, 2023 09:10
Zip something
import os
import shutil
import pprint
from datetime import datetime
#upd stamp
with open("lastupd.txt", "a") as f:
x = datetime.today().strftime('%Y-%m-%d %H:%M:%S')
f.write(x + '\n')