Skip to content

Instantly share code, notes, and snippets.

View ktaranov's full-sized avatar
🎯
Focusing

Konstantin Taranov ktaranov

🎯
Focusing
View GitHub Profile
SELECT DayDis,
[1990], [1991], [1992], [1993], [1994], [1995], [1996], [1997], [1998], [1999], [2000], [2001], [2002], [2003], [2004], [2005], [2006], [2007], [2008], [2009], [2010], [2011], [2012], [2013], [2014], [2015], [2016], [2017], [2018], [2019], [2020]
FROM
(
SELECT YEAR([Date]) AS DateYear
, CASE WHEN MONTH([Date]) < 10 THEN ('0' + CAST(MONTH([Date]) AS VARCHAR))
ELSE CAST(MONTH([Date]) AS VARCHAR)
END + '.' +
CASE WHEN DAY([Date]) < 10 THEN ('0' + CAST(DAY([Date]) AS VARCHAR))
ELSE CAST(DAY([Date]) AS VARCHAR)
@ktaranov
ktaranov / Get-ArchiveItems.ps1
Created November 27, 2019 13:54 — forked from abombss/Get-ArchiveItems.ps1
Powershell List Zip Archive File Contents
function Get-ArchiveItems {
param([Parameter(Mandatory)][string]$Archive)
function recurse-items {
param([object]$items)
foreach($item in $items) {
$item
$folder = $item.GetFolder
if ($folder) {
recurse-items $folder.Items()
@ktaranov
ktaranov / postgresql-set-id-seq.sql
Created November 21, 2019 13:40 — forked from henriquemenezes/postgresql-set-id-seq.sql
PostgreSQL set Next ID Sequence Value to MAX(id) from Table
-- Get Max ID from table
SELECT MAX(id) FROM table;
-- Get Next ID from table
SELECT nextval('table_id_seq');
-- Set Next ID Value to MAX ID
SELECT setval('table_id_seq', (SELECT MAX(id) FROM table));
@ktaranov
ktaranov / drawbrent.sql
Last active November 19, 2019 13:07 — forked from SQLAdrian/drawbrent.sql
Let's draw Brent
/* Adrian Sullivan - 2019/11/15 Fun with polygons. */
/* Thanks to Michael J Swart for all the awesome work on color https://michaeljswart.com/ */
DECLARE @tt table(id int identity(0,1), label varchar(50), gg geometry);
SET NOCOUNT ON;
DECLARE @g geometry = 'POLYGON((-121.97087 37.372518,-121.97087 37.372518,-121.970863 37.372517,-121.970845 37.372515,-121.97087 37.372518))';
DECLARE @i int = 1;
WHILE @i <= 450
@ktaranov
ktaranov / compare.py
Created October 31, 2019 14:13 — forked from sanzoghenzo/compare.py
Compare Excel sheets with Pandas
"""
Compare Excel Sheeets
Inspired by https://pbpython.com/excel-diff-pandas-update.html
"""
import argparse
import pandas as pd
import numpy as np

TSQL Example

USE master;
GO

DECLARE @nvcmaxVariable nvarchar(max);
SET @nvcmaxVariable = CONVERT(nvarchar(max), N'ಠ russian anomaly ЯЁЪ ಠ ') + N'something else' + N'another';
SELECT @nvcmaxVariable;
@ktaranov
ktaranov / README.md
Created October 9, 2019 11:48 — forked from bertspaan/README.md
Python script to convert DBF database file to CSV
# based on https://dba.meta.stackexchange.com/revisions/3e578461-07e9-46f2-b81d-a5f3e582171a/view-source
Set-Location ~/repos/git/SQL-Server-First-Responder-Kit
# https://stackoverflow.com/a/43737097/4709762
# $regexUrl='(http[s]?)(:\/\/)([^\s,]+)(?=")'
# https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url
$regexUrl = 'https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)'
import-module poshrsjob;
$DownloadDir = "/users/andy/Downloads/poshrsjob";
$MaxJobs = 3;
foreach ($i in 1..24) {
Start-RSJob -Throttle $MaxJobs -Batch "Demo" -argumentlist $i, $DownloadDir -ScriptBlock {
param($JobNum, $OutputDir)
$OutputFile = Join-Path -Path $OutputDir -ChildPath "RSJob$JobNum.zip";
Start-Sleep -Seconds (get-random -Minimum 1 -Maximum 15);
Invoke-WebRequest -uri "https://github.com/proxb/PoshRSJob/archive/master.zip" -OutFile $OutputFile;
}
@ktaranov
ktaranov / export_google_music.js
Created August 7, 2019 12:25 — forked from dcalacci/export_google_music.js
Export your Google Music Library and Playlists (Google Play Music All Access) (see http://webapps.stackexchange.com/questions/50311/print-playlist-from-google-play-music for more)
// Jeremie Miserez <[email protected]>, 2015
//
// A little bit of Javascript to let you export your Google Music library, playlists, and album track lists :)
//
// I posted this as an answer here: http://webapps.stackexchange.com/questions/50311/print-playlist-from-google-play-music
//
// 1. Go to: https://play.google.com/music/listen#/all (or your playlist)
//
// 2. Open a developer console (F12 for Chrome). Paste
// code below into the console.