Skip to content

Instantly share code, notes, and snippets.

@davidfowl
davidfowl / .NET6Migration.md
Last active April 11, 2025 11:12
.NET 6 ASP.NET Core Migration
@AlexanderPro
AlexanderPro / MS SQL
Last active July 6, 2022 14:52
SQL text log analyzer
-- Text logs
-- *******************
-- 07:30:45; Message 1
-- 07:30:47; Message 2
-- 07:30:50; Message 3
-- 08:10:01; Message 4
-- 08:10:02; Message 5
-- 08:10:03; Message 6
-- 10:25:18; Message 7
-- 10:25:19; Message 8
@meriturva
meriturva / HangfireDashboardAuthorizationFilter.cs
Last active January 25, 2023 09:23
Hangfire Dashboard Jwt Authorization Filter
public class HangfireDashboardJwtAuthorizationFilter : IDashboardAuthorizationFilter
{
private static Logger logger = LogManager.GetCurrentClassLogger();
private static readonly string HangFireCookieName = "HangFireCookie";
private static readonly int CookieExpirationMinutes = 60;
private TokenValidationParameters tokenValidationParameters;
private string role;
public HangfireDashboardJwtAuthorizationFilter(TokenValidationParameters tokenValidationParameters, string role = null)
{
@shadz3rg
shadz3rg / gost_engine.sh
Created October 15, 2018 11:19
Настройка ГОСТ OpenSSL под Ubuntu 18.04
# Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-36-generic x86_64)
# (из коробки) OpenSSL 1.1.0g 2 Nov 2017
# (из коробки) curl 7.58.0 (x86_64-pc-linux-gnu)
# PHP 7.2.10-0ubuntu0.18.04.1 (cli) (built: Sep 13 2018 13:45:02) ( NTS )
# Компилим GOST-engine
sudo apt install cmake libssl-dev
git clone --branch=openssl_1_1_0 https://github.com/gost-engine/engine.git gost-engine/engine
cd gost-engine/engine
cmake .
@primaryobjects
primaryobjects / m3u8.md
Last active September 25, 2025 04:57
How to download m3u8 and ts video movie streams.

m3u8 Downloading

  1. Open Chrome Developer tools and click the Network tab.
  2. Navigate to the page with the video and get it to start playing.
  3. Filter the list of files to "m3u8".
  4. Find master.m3u8 or index.m3u8 and click on it.
  5. Save the file to disk and look inside it.
  6. If the file contains a single m3u8 master url, copy that one instead.
  7. Run the program m3u8x.
  8. Paste the same m3u8 url in both textboxes (URL and Quality URL) and click "Headers" and set the referral url and user-agent from the request as found in Chrome.
@therightstuff
therightstuff / RSAKeys.cs
Last active October 7, 2025 09:42
Import and export RSA Keys between C# and PEM format using BouncyCastle
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.OpenSsl;
using Org.BouncyCastle.Security;
using System;
using System.IO;
using System.Security.Cryptography;
namespace MyProject.Data.Encryption
{
@anvk
anvk / psql_useful_stat_queries.sql
Last active June 1, 2025 16:17
List of some useful Stat Queries for PSQL
--- PSQL queries which also duplicated from https://github.com/anvk/AwesomePSQLList/blob/master/README.md
--- some of them taken from https://www.slideshare.net/alexeylesovsky/deep-dive-into-postgresql-statistics-54594192
-- I'm not an expert in PSQL. Just a developer who is trying to accumulate useful stat queries which could potentially explain problems in your Postgres DB.
------------
-- Basics --
------------
-- Get indexes of tables
@AtulKsol
AtulKsol / psql-error-fix.md
Last active September 30, 2025 18:28
Solution of psql: FATAL: Peer authentication failed for user “postgres” (or any user)

psql: FATAL: Peer authentication failed for user “postgres” (or any user)

The connection failed because by default psql connects over UNIX sockets using peer authentication, that requires the current UNIX user to have the same user name as psql. So you will have to create the UNIX user postgres and then login as postgres or use sudo -u postgres psql database-name for accessing the database (and psql should not ask for a password).

If you cannot or do not want to create the UNIX user, like if you just want to connect to your database for ad hoc queries, forcing a socket connection using psql --host=localhost --dbname=database-name --username=postgres (as pointed out by @meyerson answer) will solve your immediate problem.

But if you intend to force password authentication over Unix sockets instead of the peer method, try changing the following pg_hba.conf* line:

from

@Eun
Eun / project.csproj
Created November 16, 2016 10:02
ILMerge AfterBuild
<Target Name="AfterBuild" Condition="'$(Configuration)'=='Release'">
<CreateItem Include="$(SolutionDir)\packages\ILMerge.*\tools\ILMerge.exe">
<Output TaskParameter="Include" ItemName="ILMergeExe" />
</CreateItem>
<Error Text="@(ILMergeExe) does not exists" Condition="!Exists('@(ILMergeExe)')" />
<CreateItem Include="@(ReferencePath)" Condition="'%(CopyLocal)'=='true'">
<Output TaskParameter="Include" ItemName="ILMergeAssemblies" />
</CreateItem>
<Delete Files="$(OutputPath)\ILMerge.log" Condition="Exists('$(OutputPath)\ILMerge.log')" />
<Exec Command="&quot;@(ILMergeExe)&quot; /ndebug /log:$(OutputPath)\ILMerge.log /out:@(MainAssembly) &quot;@(IntermediateAssembly)&quot; @(ILMergeAssemblies-&gt;'&quot;%(FullPath)&quot;', ' ')" />
@broofa
broofa / pre-commit
Last active June 9, 2025 10:24
Git pre-commit hook that runs `eslint` with the `--fix` option to fix up issues where possible, and adds "fix"ed files into the commit
#!/bin/bash
cd "$(git rev-parse --show-toplevel)"
ESLINT="node_modules/.bin/eslint"
pwd
if [[ ! -x "$ESLINT" ]]; then
printf "\t\033[41mPlease install ESlint\033[0m (npm install eslint)\n"
exit 1
fi