Skip to content

Instantly share code, notes, and snippets.

View mac2000's full-sized avatar

Alexandr Marchenko mac2000

View GitHub Profile
@mac2000
mac2000 / create-docker-tls.sh
Last active March 1, 2018 00:57 — forked from Stono/create-docker-tls.sh
Creating and setting up Docker for TLS
#!/bin/bash
# At the end you will have 6 files:
# ca/ca.pem - used by both client and server to verify each other certificates
# ca/ca-key.pem - keep it in secret it may be used to generate new certificates
# client/cert.pem, client/key.pem - in conjunction with /ca/ca.pem will be used by client to speak with server
# server/cert.pem, server/key.pem - in conjunction with /ca/ca.pem will be used by server
#
# NOTICE: DO NOT FORGET to set your **Server** ip and dns in server/openssl.cnf each time you generating new server certificates
#
@mac2000
mac2000 / webstorm.cmd
Last active September 1, 2020 18:46 — forked from amnuts/phpstorm.bat
Open with WebStorm context menu
@ECHO OFF
REM Remove registry if any
REG DELETE "HKEY_CLASSES_ROOT\Directory\shell\WebStorm" /f
REM Get WebStorm executable path
FOR /F "usebackq tokens=3*" %%A IN (`REG QUERY "HKEY_CLASSES_ROOT\Applications\WebStorm.exe\shell\open\command"`) DO (
SET WEBSTORM=%%A %%B
)
@mac2000
mac2000 / cloudSettings
Last active February 18, 2017 18:35
Visual Studio Code Sync Settings Gist
{"lastUpload":"2017-02-18T18:35:28.986Z","extensionVersion":"v2.4.3"}
@mac2000
mac2000 / sql 2017 graph demo.sql
Created August 13, 2017 17:44
sql 2017 graph demo
-- docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=P@ssword" -e "MSSQL_PID=Developer" --cap-add SYS_PTRACE -p 1433:1433 --name sql -it --rm -v C:/Users/AlexandrM/Downloads/ml-100k:/ml-100k -v C:/Users/AlexandrM/Downloads/ml-20m:/ml-20m microsoft/mssql-server-linux
-- http://files.grouplens.org/datasets/movielens/ml-20m.zip
use master;
go
DROP DATABASE movies;
GO
-- Create a graph demo database
CREATE DATABASE movies;
@mac2000
mac2000 / bigquery_cf.sql
Created August 19, 2017 18:47
bigquery recommendations based on user ratings
WITH d AS (
-- should return (cid - user id, vid - item id, rating)
SELECT
clientId as cid,
REGEXP_EXTRACT(page.pagePath, r'/company\d+/vacancy(\d+)') AS vid,
MAX(
CASE
WHEN page.pagePath LIKE '%apply=thanks%' THEN 5
WHEN page.pagePath LIKE '%mode=apply%' THEN 2
@mac2000
mac2000 / teamcity_rename_vsc.py
Created March 12, 2018 10:22
TeamCity mass vcs rename via API
from getpass import getpass
import json
import re
import requests # pip3 install requests
username = input('Username: ')
password = getpass()
# username = 'AlexandrM'
# password = '********'
auth = (username, password)
@mac2000
mac2000 / index.html
Created March 25, 2018 11:28
brain.js demo
<!DOCTYPE html>
<html>
<head>
<title>brain.js</title>
<script src="https://cdn.rawgit.com/BrainJS/brain.js/develop/browser.js"></script>
<script>
function DrawableCanvas(el) {
const px = 10
const ctx = el.getContext('2d')
let x = []
@mac2000
mac2000 / demo.sh
Created May 9, 2020 08:13
kafka local dev environment
docker-compose up
# optional: open local control center
open http://localhost:9021
# demo 1
# ------
# create topic
docker exec -it broker kafka-topics --bootstrap-server localhost:9092 --create --topic demo1 --partitions 3 --replication-factor 1
@mac2000
mac2000 / Program.cs
Last active May 18, 2020 11:26
dotnet multiple jwt bearer
using System;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using System.Text;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
@mac2000
mac2000 / exam.md
Last active September 22, 2021 18:36
otus pg notes

Final HW

Slides

Решаем две задачи: с одной стороны отказоустойчивый и масштабируемый класстер на базе cockroachdb, а с другой, авто генерируемая админка к его табличкам

TLDR

Для запуска необходимо выполнить