Skip to content

Instantly share code, notes, and snippets.

View alexesDev's full-sized avatar

Alexey Yurchenko alexesDev

  • Digital Nomad
View GitHub Profile
@ashwin
ashwin / randgen.cpp
Created August 27, 2014 14:46
Random number generation in C++11
#include <iostream>
#include <limits>
#include <random>
int main()
{
std::default_random_engine eng((std::random_device())());
std::uniform_int_distribution<int8_t> idis(0, std::numeric_limits<int8_t>::max());
for (int i = 0; i < 10; ++i)
setxkbmap -layout dvp,ru
setxkbmap -option grp:caps_toggle
xrdb ~/.Xresources
sudo netctl start wlp5s1-FRESH_OFFICE &
chromium &
telegram-desktop &
#!/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"
@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 = '{}'
);
@mosra
mosra / README.md
Last active December 17, 2017 15:57
cosi, minimal stuff for easier soci + picojson usage

Usage

First, create the named tuple from list of cosi::field instances. First parameter is name in resulting JSON, second is optional field name in SQL query. If not used, the same name is used for both JSON and SQL.

auto t = cosi::make(
    cosi::string_f  {"data"},
    cosi::int_f     {"integerData", "COUNT(data)"},
    cosi::double_f  {"moreData", "another_table.data"}

);

@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 / 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
@lechup
lechup / slugify.sql
Last active November 11, 2018 16:54 — forked from thomasbilk/slugify.sql
Pseudo Transliteration for Postgres aka `slugify`
CREATE OR REPLACE FUNCTION slugify(str text) RETURNS text AS $$
BEGIN
RETURN regexp_replace(
lower(translate(str,
'äëïöüáéíóúâêîûôåãõàèìòùřšěčůńýśćłęążźĄŃÝŚĆŁĘÄËÏÖÜÁÉÍÓÚÂÊÎÛÔÅÃÕÀÈÌÒÙŘŠĚČŮŻŹß ²ø®',
'aeiouaeiouaeiouaaoaeioursecunyscleazzANYSCLEAEIOUAEIOUAEIOUAAOAEIOURSECUZzs-2dR'
-- missing chars will be removed
)),
-- strip all others chars than [^a-z0-9 \-]
'[^a-z0-9 \-]',
#!/bin/bash
set -eux
set -o pipefail
cd /tmp
git clone https://robot:foo@gitea.vrutkovs.eu/vadim/cluster-state.git
cd cluster-state
rm -rf ./*
# Globals
// 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.
*