Skip to content

Instantly share code, notes, and snippets.

View demidovsky's full-sized avatar

Dmitry Demidovsky demidovsky

View GitHub Profile
@demidovsky
demidovsky / postman_vs_insomnia_comparison.md
Created May 1, 2023 23:21 — forked from samoshkin/postman_vs_insomnia_comparison.md
Comparison of API development environments: Postman vs Insomnia

Postman vs Insomnia comparison

Postman | API Development Environment https://www.getpostman.com
Insomnia REST Client - https://insomnia.rest/

Features                                        Insomnia Postman Notes
Create and send HTTP requests x x
Authorization header helpers x x Can create "Authorization" header for you for different authentication schemes: Basic, Digest, OAuth, Bearer Token, HAWK, AWS
// In place quicksort
function inplace_quicksort_partition(ary, start, end, pivotIndex) {
var i = start, j = end;
var pivot = ary[pivotIndex];
while(true) {
while(ary[i] < pivot) {i++};
j--;
while(pivot < ary[j]) {j--};
if(!(i<j)) {
@demidovsky
demidovsky / rgb-hsv.js
Created September 29, 2021 06:37
RGB <-> HSV conversion
// input: h in [0,360] and s,v in [0,1]
// output: r,g,b in [0,1]
hsv2rgb(h,s,v) {
const f= (n,k=(n+h/60)%6) => v - v*s*Math.max( Math.min(k,4-k,1), 0);
return [f(5),f(3),f(1)];
}
// input: r,g,b in [0,1]
// output: h in [0,360) and s,v in [0,1]
echo 'please wait...' && sudo lsof -i -P | grep -i "LISTEN"
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
@demidovsky
demidovsky / default
Created September 27, 2019 10:46
nginx + certbot (letsencrypt) config example
#/etc/nginx/sites-enabled/default
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 301 https://$host$request_uri;
}
server {

Check all non-Apple installed services:

launchctl list | grep -v com.apple

Get active services:

grep -B 1 -A 1 "active count = 1$" <<< "$(launchctl dumpstate)"
// Restify Server CheatSheet.
// More about the API: http://mcavage.me/node-restify/#server-api
// Install restify with npm install restify
// 1.1. Creating a Server.
// http://mcavage.me/node-restify/#Creating-a-Server
var restify = require('restify');
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
Right-click on the right side, and add a new DWORD (32-bit) Value
Set the value name to DisableTaskOffload and the value data to 1
Open Network Connections.
Right-click the icon of the Network card and select Properties.
In Networking tab, click Configure… button.
In the next window, switch to Advanced tab.
Click the Large Send Offload Version 2 (IPv4) and change the value to Disabled.