Skip to content

Instantly share code, notes, and snippets.

View mgramin's full-sized avatar

Maksim Gramin mgramin

View GitHub Profile
select с.country_id
, cnt.country
, с.cities_per_country_count
, floor(cities_per_country_count / cities_count * 100) as percent
from (select country_id
, count(1) as cities_per_country_count
, sum(count(1)) over () as cities_count
from city
group by country_id) с
join country cnt on cnt.country_id = с.country_id
SELECT faker.faker(ARRAY['en_US']);
delete from rental;
delete from inventory;
delete from film;
delete from staff;
delete from customer;
delete from store;
delete from address;
delete from city;
first_name last_name email address order_date
Joshua Brooks jenniferhernandez@barker.com 800 Erickson Place Apt. 712 Jessicachester, WV 70233 1994-05-07
Matthew Garcia calderonphilip@brewer.com 49350 Jennifer Curve Apt. 883 Cathyberg, OK 03090 2021-09-09
Taylor Mccoy gallowayeric@hotmail.com 64912 Smith Cove Lake Fernando, AZ 72732 2013-12-15
Amanda Craig joankoch@taylor.info 19837 Mccarthy Vista West Kristopher, OR 44847 2000-11-29
@mgramin
mgramin / sql_educational_plan.md
Last active September 27, 2022 16:43
SQL Educational Plan

SQL educational plan

0. Setup environment

Topics:

  • What is DBeaver (GUI tool for working with databases)?

Tasks:

Hello World!

@mgramin
mgramin / relational_Interval_tree.sql
Created January 25, 2022 19:37
Relational Interval Tree Example
CREATE TABLE test(text value, int node_id, int left_bound_id, int right_bound_id);
INSERT INTO test VALUES ('Food', 0, 1, 10000);
INSERT INTO test VALUES ('Fruit', 100, 101, 199);
INSERT INTO test VALUES ('Cherry', 101, null, null);
INSERT INTO test VALUES ('Banana', 102, null, null);
INSERT INTO test VALUES ('Meat', 200, 201, 299);
INSERT INTO test VALUES ('Beaf', 201, null, null);
INSERT INTO test VALUES ('Pork', 202, null, null);
@mgramin
mgramin / run.py
Last active March 31, 2024 11:40
Simple REST service for osquery
from flask import Flask, request
from flask_restful import Api, Resource
import osquery
class User(Resource):
@staticmethod
def get():
instance = osquery.SpawnInstance()
instance.open()
query = request.args.get('query', default='', type=str)
@mgramin
mgramin / delete_all_gh_releases.py
Created April 4, 2019 11:38
Delete all GitHub releases and tags
import requests
from requests import Response
from requests.auth import HTTPBasicAuth
releases_url = 'https://api.github.com/repos/sql-boot/sql-boot/releases'
for o in requests.get(releases_url).json():
print(o['id'])
delete = requests.delete(releases_url + '/' + str(o['id']), auth=HTTPBasicAuth('USER', 'PASSWORD'))
print(releases_url + '/' + str(o['id']))
call plug#begin('~/.vim/plugged')
Plug 'junegunn/seoul256.vim'
Plug 'junegunn/vim-easy-align'
" On-demand loading
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
"
" " Using git URL