Skip to content

Instantly share code, notes, and snippets.

View Tirael's full-sized avatar
🏠
Working from home

Georgiy Zhuykov Tirael

🏠
Working from home
  • Moscow, Moscow City, Russian Federation
View GitHub Profile
@Tirael
Tirael / large_test.sql
Created May 30, 2019 11:39
postgresql create/insert to large_test
create or replace function random_between(low int, high int)
returns int as
$$
begin
return floor(random() * (high-low + 1) + low);
end;
$$ language 'plpgsql' strict;
--
do $$
declare start_ts timestamp;
@Tirael
Tirael / LargestTriangleThreeBuckets.cs
Created June 7, 2019 12:30 — forked from DanielWJudge/LargestTriangleThreeBuckets.cs
Largest-Triangle-Three Bucket Downsampling Graphs in C#
public static IEnumerable<Tuple<double, double>> LargestTriangleThreeBuckets(List<Tuple<double, double>> data, int threshold)
{
int dataLength = data.Count;
if (threshold >= dataLength || threshold == 0)
return data; // Nothing to do
List<Tuple<double, double>> sampled = new List<Tuple<double, double>>(threshold);
// Bucket size. Leave room for start and end data points
double every = (double)(dataLength - 2) / (threshold - 2);
@Tirael
Tirael / LTTBD.cs
Created June 7, 2019 12:31 — forked from adrianseeley/LTTBD.cs
Largest-Triangle-Three Bucket Downsampling Graphs in C# (For an Array of Floats) http://i.imgur.com/UwhvV45.png
public float[] Downsample(float[] array, int Length)
{
int insert = 0;
float[] window = new float[Length];
float[] window_x = new float[Length];
int bucket_size_less_start_and_end = Length - 2;
float bucket_size = (float)(array.Length - 2) / bucket_size_less_start_and_end;
int a = 0;
int next_a = 0;
@Tirael
Tirael / shrug.ahk
Created June 7, 2019 14:36 — forked from dieseltravis/shrug.ahk
autohotkey script to replace 🤷 with ¯\_(ツ)_/¯ (and a few other common unicode art emoji)
; :shrug: ¯\_(ツ)_/¯
:B0:`:shrug::
if (A_EndChar == ":") {
SendInput, {BS 7}¯\_(ツ)_/¯
}
return
; :whatever: ◔_◔
:B0:`:whatever::
Backup:
docker exec -t -u postgres your-db-container pg_dumpall -c > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
Restore:
cat your_dump.sql | docker exec -i your-db-container psql -Upostgres
@Tirael
Tirael / RestSharpExecuteAsyncMoq.cs
Created May 12, 2020 21:36 — forked from mrstebo/RestSharpExecuteAsyncMoq.cs
Example for mocking RestSharps IRestClient ExecuteAsync method using Moq
using Moq;
using NUnit.Framework;
using RestSharp;
using System;
using System.Net;
namespace RestsharpTests
{
[TestFixture]
public class RestsharpExecuteAsyncMoq
@Tirael
Tirael / LetsEncrypt_HTTPS_plex.MD
Created June 3, 2020 18:13 — forked from churro-s/LetsEncrypt_HTTPS_plex.MD
Setup Let's Encrypt certificate for use with Plex Media Server on Ubuntu
@Tirael
Tirael / ForEachAsync.cs
Created June 5, 2020 11:41 — forked from 0xced/ForEachAsync.cs
Parallel foreach async enumeration with maximum degree of parallelism
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Parallel
{
public static class EnumerableExtensions
{
using Jaeger.Reporters;
using Jaeger.Samplers;
using Jaeger.Senders;
using Jaeger.Senders.Thrift;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using OpenTracing;
@Tirael
Tirael / gist:6fce2f75ac01e4a84da31fdd59220f76
Last active August 30, 2020 20:22
Kafka + strimzi (Windows)
choco install sed
kubectl create ns kafka
# curl -L http://strimzi.io/install/latest | sed "s/namespace: .*/namespace: kafka/" | kubectl apply -f - -n kafka