Skip to content

Instantly share code, notes, and snippets.

View mac2000's full-sized avatar

Alexandr Marchenko mac2000

View GitHub Profile
@mac2000
mac2000 / dismissable.swift
Created March 17, 2024 19:16
dismissable
import SwiftUI
struct DismissableNavigationLinkDetailView: View {
@Environment(\.dismiss) var dismiss
@Binding var item: String?
let items = ["Item 1", "Item 2", "Item 3", "Item 4"]
var body: some View {
List(selection: $item) {
ForEach(items, id: \.self, content: Text.init)
}
<?xml version="1.0" encoding="UTF-8" ?>
<root>
<Symbol>AAPL</Symbol>
<AssetType>Common Stock</AssetType>
<Name>Apple Inc</Name>
<Description>Apple Inc. is an American multinational technology company that specializes in consumer electronics, computer software, and online services. Apple is the world&#x27;s largest technology company by revenue (totalling $274.5 billion in 2020) and, since January 2021, the world&#x27;s most valuable company. As of 2021, Apple is the world&#x27;s fourth-largest PC vendor by unit sales, and fourth-largest smartphone manufacturer. It is one of the Big Five American information technology companies, along with Amazon, Google, Microsoft, and Facebook.</Description>
<CIK>320193</CIK>
<Exchange>NASDAQ</Exchange>
<Currency>USD</Currency>
<Country>USA</Country>
@mac2000
mac2000 / highlight.js
Created August 25, 2023 08:13
highlight.js
function highlight(line) {
const highlighted = line
.replace(/[\0-\x1F\x7F-\x9F\xAD\u0378\u0379\u037F-\u0383\u038B\u038D\u03A2\u0528-\u0530\u0557\u0558\u0560\u0588\u058B-\u058E\u0590\u05C8-\u05CF\u05EB-\u05EF\u05F5-\u0605\u061C\u061D\u06DD\u070E\u070F\u074B\u074C\u07B2-\u07BF\u07FB-\u07FF\u082E\u082F\u083F\u085C\u085D\u085F-\u089F\u08A1\u08AD-\u08E3\u08FF\u0978\u0980\u0984\u098D\u098E\u0991\u0992\u09A9\u09B1\u09B3-\u09B5\u09BA\u09BB\u09C5\u09C6\u09C9\u09CA\u09CF-\u09D6\u09D8-\u09DB\u09DE\u09E4\u09E5\u09FC-\u0A00\u0A04\u0A0B-\u0A0E\u0A11\u0A12\u0A29\u0A31\u0A34\u0A37\u0A3A\u0A3B\u0A3D\u0A43-\u0A46\u0A49\u0A4A\u0A4E-\u0A50\u0A52-\u0A58\u0A5D\u0A5F-\u0A65\u0A76-\u0A80\u0A84\u0A8E\u0A92\u0AA9\u0AB1\u0AB4\u0ABA\u0ABB\u0AC6\u0ACA\u0ACE\u0ACF\u0AD1-\u0ADF\u0AE4\u0AE5\u0AF2-\u0B00\u0B04\u0B0D\u0B0E\u0B11\u0B12\u0B29\u0B31\u0B34\u0B3A\u0B3B\u0B45\u0B46\u0B49\u0B4A\u0B4E-\u0B55\u0B58-\u0B5B\u0B5E\u0B64\u0B65\u0B78-\u0B81\u0B84\u0B8B-\u0B8D\u0B91\u0B96-\u0B98\u0B9B\u0B9D\u0BA0-\u0BA2\u0BA5-\u0BA7\u0BAB-\u0BAD\u0BB
@mac2000
mac2000 / deployment.yaml
Created July 23, 2023 07:28
kustomize repro
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-nginx
spec:
selector:
matchLabels:
run: my-nginx
replicas: 2
template:
@mac2000
mac2000 / aad-proxy.go
Created November 22, 2021 07:59
kubernetes auth-proxy
package main
import (
"context"
"crypto/rand"
"encoding/base64"
"encoding/json"
"fmt"
"io"
"log"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link type="text/css" rel="stylesheet" href="https://source.zoom.us/1.9.8/css/bootstrap.css" />
<link type="text/css" rel="stylesheet" href="https://source.zoom.us/1.9.8/css/react-select.css" />
<style>
@mac2000
mac2000 / postgres_master_slave_failover_failback.md
Last active June 28, 2024 08:23
Postgres Master Slave Failover & Failback

Postgres Master Slave Failover & Failback

video

start

docker run -it --rm -p 5551:5432 --name=db1 --hostname=db1 ubuntu:20.04 bash
docker run -it --rm -p 5552:5432 --name=db2 --hostname=db2 ubuntu:20.04 bash
@mac2000
mac2000 / exam.md
Last active September 22, 2021 18:36
otus pg notes

Final HW

Slides

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

TLDR

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

@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 / 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