Skip to content

Instantly share code, notes, and snippets.

View alexesDev's full-sized avatar

Alexey Yurchenko alexesDev

  • nonono
View GitHub Profile
// Must disable logging if using logging in main.cpp or in other custom components for the
// __c causes a section type conflict with __c thingy
// you can enable logging and use it if you enable this in logger:
/*
logger:
level: DEBUG
esp8266_store_log_strings_in_flash: False
*/
//#define APE_LOGGING
@lucasrenan
lucasrenan / k8s.sh
Created April 30, 2019 17:50
Kubernetes get all pods/containers resources requests/limits
kubectl get pods --all-namespaces --sort-by='.metadata.name' -o jsonpath='{.items[*].spec.containers[*].resources.limits.memory}'
kubectl get pod --all-namespaces --sort-by='.metadata.name' -o json | jq -r '[.items[] | {pod_name: .metadata.name, containers: .spec.containers[] | [ {container_name: .name, memory_requested: .resources.requests.memory, cpu_requested: .resources.requests.cpu} ] }]'
@pohzipohzi
pohzipohzi / walg-pitr.md
Last active April 25, 2023 15:47
PostgreSQL Point-In-Time-Recovery (PITR) with WAL-G

WAL-G PITR

This gist summarises a way to simulate point-in-time recovery (PITR) using WAL-G. Most of the material is adapted from Creston's tutorial.

Setup

First we initialize a database cluster

pg_ctl init -D cluster
#!/bin/bash
set -eux
set -o pipefail
cd /tmp
git clone https://robot:[email protected]/vadim/cluster-state.git
cd cluster-state
rm -rf ./*
# Globals
@mixin lhCrop($line-height) {
&::before {
content: '';
display: block;
height: 0;
width: 0;
margin-top: calc((1 - #{$line-height}) * 0.5em);
}
}
@alexesDev
alexesDev / run.sql
Created March 13, 2018 09:31
Postgres security row polises with sessions vars
set role api; set session app.current_user_id to 1; select * from app_users;
id | first_name
----+------------
1 | john
2 | max
set role api; set session app.current_user_id to 2; select * from app_users;
id | first_name
// Based on https://github.com/facebook/relay/blob/master/packages/react-relay/modern/ReactRelayQueryRenderer.js
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
@alexesDev
alexesDev / CircleRenderer.cpp
Last active January 4, 2018 20:48
Simple CircleRenderer feature for margum engine
#include "CircleRenderer.h"
#include "Types.h"
#include <Magnum/Mesh.h>
#include <Magnum/Buffer.h>
#include <Magnum/SceneGraph/Camera.h>
#include <Magnum/Shaders/Flat.h>
#include <Magnum/Primitives/Circle.h>
#include <Magnum/Trade/MeshData2D.h>
@alexesDev
alexesDev / array_agg_mult.sql
Last active November 24, 2017 09:15
Выборка заказов из PG для обучения нейронной сети (тормознутый вариант, потому что генерирует много дубльданных для удобства)
-- array_agg не поддерживает массивы
create aggregate array_agg_mult(anyarray) (
SFUNC = array_cat,
STYPE = anyarray,
INITCOND = '{}'
);
#!/bin/bash
ADDR=$1
echo $ADDR
firewall-cmd --permanent --zone=drop --add-rich-rule="
rule family='ipv4'
source address=${ADDR}
port protocol='tcp' port='2377' accept"