Skip to content

Instantly share code, notes, and snippets.

View alesmenzel's full-sized avatar
:octocat:

Aleš Menzel alesmenzel

:octocat:
  • Emplifi
  • Prague
View GitHub Profile
@alesmenzel
alesmenzel / yify.md
Created April 9, 2020 18:56 — forked from kuntau/yify.md
YIFY's Quality Encoding

For those that want to keep the YTS going (No, IDGAF about people that don't care for YTS quality) get HandbrakeCLI https://handbrake.fr/downloads... and use the following settings:

user@user:~$HandBrakeCLI -i /file/input.mp4 -o /file/out.mp4 -E fdk_faac -B 96k -6 stereo -R 44.1 -e x264 -q 27 -x cabac=1:ref=5:analyse=0x133:me=umh:subme=9:chroma-me=1:deadzone-inter=21:deadzone-intra=11:b-adapt=2:rc-lookahead=60:vbv-maxrate=10000:vbv-bufsize=10000:qpmax=69:bframes=5:b-adapt=2:direct=auto:crf-max=51:weightp=2:merange=24:chroma-qp-offset=-1:sync-lookahead=2:psy-rd=1.00,0.15:trellis=2:min-keyint=23:partitions=all

Reason to use CLI over GTK has to do with lack of support for advanced settings for Handbrake GTK

** Don't Re-encode already shitty encodes...get good source!**

@alesmenzel
alesmenzel / PostgreSQL_index_naming.rst
Created March 13, 2020 16:12 — forked from popravich/PostgreSQL_index_naming.rst
PostgreSQL index naming convention to remember

The standard names for indexes in PostgreSQL are:

{tablename}_{columnname(s)}_{suffix}

where the suffix is one of the following:

  • pkey for a Primary Key constraint;
  • key for a Unique constraint;
  • excl for an Exclusion constraint;
  • idx for any other kind of index;

Simple removal of debug module

Common usage of the debug module is for development and then disable it in production (usually also have a separate logger for production issues). Thus the code is shipped without a purpose and also it can have some perf. implication. E.g. imagine you log some big object debug('Some big object', JSON.stringify(largeObject). The JSON.stringify runs even if we disable the module, waisting precious resources - the correct usage of the module is to use formatters, e.g debug('Some big object %o', largeObject), but i have rarely seen someone use it. To avoid this common pitfalls, we can remove the debug module from our code completely - saving bundle size and performance.

Example:

https://astexplorer.net/#/gist/1652612fd62624282390aa74883beeb8/9c46a23a73496cea19d550f3a45ee8d335988054

How to use

@alesmenzel
alesmenzel / service-workers.md
Created February 22, 2019 20:26 — forked from Rich-Harris/service-workers.md
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@alesmenzel
alesmenzel / combinations.js
Last active August 28, 2018 20:40
Combination of k elements from an array
const k_combinations = (arr, k) => {
if (arr.length < k) {
return [];
}
if (arr.length === k) {
return [arr];
}
if (k === 1) {
@alesmenzel
alesmenzel / pick-random-element-based-on-probability.js
Last active July 25, 2025 05:22
Select random element from array by probability
const arr = ['A', 'B', 'C'];
// Probability map
const weight = {
A: 0.5,
B: 0.3,
C: 0.2
};
const find = input =>
@alesmenzel
alesmenzel / OpenSSL cheat sheet for socket programmers.md
Created August 12, 2018 19:41 — forked from azadkuh/OpenSSL cheat sheet for socket programmers.md
OpenSSL cheat sheet. This is a brief howto for socket programmers.

#OpenSSL cheat sheet This is a brief howto for socket programmers.

create RSA key pairs

ex: 1024bits length key pair:

$> openssl genrsa -out myprivate.pem 1024
$> openssl rsa -in myprivate.pem -pubout -out mypublic.pem
@alesmenzel
alesmenzel / README.md
Created August 12, 2018 19:24 — forked from pcan/README.md
Node.js plain TLS Client & Server, 2-way Cert Auth

Node.js TLS plain TLS sockets

This guide shows how to set up a bidirectional client/server authentication for plain TLS sockets.

Prepare certificates

Generate a Certificate Authority:

openssl req -new -x509 -days 9999 -keyout ca-key.pem -out ca-crt.pem
@alesmenzel
alesmenzel / tcpproxy.js
Created July 15, 2018 16:38 — forked from kfox/tcpproxy.js
A basic TCP proxy written in node.js
var net = require("net");
process.on("uncaughtException", function(error) {
console.error(error);
});
if (process.argv.length != 5) {
console.log("usage: %s <localport> <remotehost> <remoteport>", process.argv[1]);
process.exit();
}
@alesmenzel
alesmenzel / event-loop.md
Created July 15, 2018 07:46 — forked from jesstelford/event-loop.md
What is the JS Event Loop and Call Stack?

Regular Event Loop

This shows the execution order given JavaScript's Call Stack, Event Loop, and any asynchronous APIs provided in the JS execution environment (in this example; Web APIs in a Browser environment)


Given the code