Skip to content

Instantly share code, notes, and snippets.

View supix's full-sized avatar

supix supix

View GitHub Profile
supix / grep.yaml
Last active March 21, 2022 15:36
Check whether a string is found through grep
View grep.yaml
- name: Check if a string is found through grep
hosts: all
filename: /tmp/rc.txt
dst_folder: /tmp/hosts
- name: delete the centralized file
supix / gather_kernel_version.yaml
Last active March 21, 2022 15:40
Ansible playbook useful to gather the host kernel version
View gather_kernel_version.yaml
- name: gather kernel version
hosts: all
filename: /tmp/kernelv.txt
dst_folder: /tmp/hosts
- name: delete the centralized file
supix / yum
Created July 29, 2021 09:11
yum command to find all the CVEs a system is affected by
View yum
yum updateinfo list cves
supix /
Last active November 4, 2020 15:41
Useful development resource
supix / GetLoggedUser.cs
Last active November 15, 2022 17:51
Enabling JWT integration in a net core WebApi project
View GetLoggedUser.cs
using Microsoft.AspNetCore.Http;
internal class GetLoggedUser : IGetLoggedUser
private readonly IHttpContextAccessor httpContextAccessor;
public GetLoggedUser(IHttpContextAccessor httpContextAccessor)
this.httpContextAccessor = httpContextAccessor ?? throw new ArgumentNullException(nameof(httpContextAccessor));
supix / asyncVersion.cs
Last active August 30, 2018 09:57
Simple console application demonstrating how async programming allows to save time
View asyncVersion.cs
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp1
internal class Program
private static void Main(string[] args)
supix /
Last active November 22, 2023 08:46
Postgres error: Missing chunk 0 for toast value in pg_toast

The problem

In some cases, it is possible that PostgreSQL tables get corrupted. This can happen in case of hardware failures (e.g. hard disk drives with write-back cache enabled, RAID controllers with faulty/worn out battery backup, etc.), as clearly reported in this wiki page. Furthermore, it can happen in case of incorrect setup, as well.

One of the symptoms of such corruptions is the following message:

ERROR: missing chunk number 0 for toast value 123456 in pg_toast_45678

This almost surely indicates that a corrupted chunk is present within a table file. But there is a good way to get rid of it.

supix /
Last active June 19, 2018 07:11
Applying Bayes Theorem and verifying if through frequentist probability approach


We are in a university campus. There are two faculties: math and business administration. 10% of student are enrolled in math (then, 90% of students are enrolled in business administration). Within math faculty, 75% students are shy. Within business administration, 15% students are shy.


I see a student, and he is clearly shy. What's the probability that he is enrolled in math faculty?

Theoretical solution through Bayes Theorem

supix / DbContext.cs
Last active December 15, 2022 21:22
Sample C# MongoDb setup
View DbContext.cs
using MongoDB.Bson;
using MongoDB.Bson.Serialization;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Bson.Serialization.IdGenerators;
using MongoDB.Bson.Serialization.Serializers;
using MongoDB.Driver;
namespace Persistence.MongoDB
internal class DbContext
supix / index.html
Last active May 5, 2018 20:32
Angular template for a website with top nav menu and fixed width
View index.html
<div class="topnav">
<a class="active" href="#home">Home</a>
<a href="#news">News</a>
<a href="#contact">Contact</a>
<a href="#about">About</a>
<div class="content">