Skip to content

Instantly share code, notes, and snippets.

View uzbekdev1's full-sized avatar
🌴
On vacation

Elyor Latipov uzbekdev1

🌴
On vacation
View GitHub Profile
@uzbekdev1
uzbekdev1 / encrypt_password.py
Created September 10, 2021 20:56 — forked from jkatz/encrypt_password.py
Methods to create password verifiers for PostgreSQL
"""
Generate the password hashes / verifiers for use in PostgreSQL
How to use this:
pw = EncryptPassword(
user="username",
password="securepassword",
algorithm="scram-sha-256",
)
@uzbekdev1
uzbekdev1 / nginx.conf
Created August 23, 2021 10:51
Nginx 404 error with existing urls Angular
location / {
try_files $uri $uri/ /index.html;
}
@uzbekdev1
uzbekdev1 / sleep.js
Last active August 5, 2021 21:36
JavaScript sleep
const sleep = (milliseconds) => {
return new Promise(resolve => setTimeout(resolve, milliseconds))
}
async testWaiter(){
await sleep(1000);
console.log('Wait a 1 second');
}
@uzbekdev1
uzbekdev1 / sysroot.cs
Created August 3, 2021 20:35
C# get system root folder
Environment.GetFolderPath(Environment.SpecialFolder.System).Replace("system32", "")
package main
import (
"fmt"
"reflect"
)
//function types
type mapf func(interface{}) interface{}
@uzbekdev1
uzbekdev1 / CountryCodes.json
Created July 27, 2021 21:17 — forked from Goles/CountryCodes.json
Country and Dial or Phone codes in JSON format
[{"name":"Israel","dial_code":"+972","code":"IL"},{"name":"Afghanistan","dial_code":"+93","code":"AF"},{"name":"Albania","dial_code":"+355","code":"AL"},{"name":"Algeria","dial_code":"+213","code":"DZ"},{"name":"AmericanSamoa","dial_code":"+1 684","code":"AS"},{"name":"Andorra","dial_code":"+376","code":"AD"},{"name":"Angola","dial_code":"+244","code":"AO"},{"name":"Anguilla","dial_code":"+1 264","code":"AI"},{"name":"Antigua and Barbuda","dial_code":"+1268","code":"AG"},{"name":"Argentina","dial_code":"+54","code":"AR"},{"name":"Armenia","dial_code":"+374","code":"AM"},{"name":"Aruba","dial_code":"+297","code":"AW"},{"name":"Australia","dial_code":"+61","code":"AU"},{"name":"Austria","dial_code":"+43","code":"AT"},{"name":"Azerbaijan","dial_code":"+994","code":"AZ"},{"name":"Bahamas","dial_code":"+1 242","code":"BS"},{"name":"Bahrain","dial_code":"+973","code":"BH"},{"name":"Bangladesh","dial_code":"+880","code":"BD"},{"name":"Barbados","dial_code":"+1 246","code":"BB"},{"name":"Belarus","dial_code":"+375","
@uzbekdev1
uzbekdev1 / demo.cs
Last active July 24, 2021 10:22
LINQ - DistinctBy
var query = people.DistinctBy(p => p.Id);
var query = people.DistinctBy(p => new { p.Id, p.Name });
@uzbekdev1
uzbekdev1 / date.cs
Created June 25, 2021 16:59
C# long ticks to DateTime
var firstDate = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
var nowNicks=1624640349103;
var currentDate= firstDate.AddMilliseconds(nowNicks).ToLocalTime();
@uzbekdev1
uzbekdev1 / number_format.js
Created June 21, 2021 12:01
JavaScriipt number format
function number_format(number, decimals, dec_point, thousands_sep) {
// http://kevin.vanzonneveld.net
// + original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + bugfix by: Michael White (http://getsprink.com)
// + bugfix by: Benjamin Lupton
// + bugfix by: Allan Jensen (http://www.winternet.no)
// + revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
// + bugfix by: Howard Yeend
In this post, .net platform has this pinvoke mechanism where it is allowed that you call into the Native windows .
this is extremely useful when you have some 3rd party libraries or if you try to program against with the low-level windows APIS.
One of the typic application htat utilize the Lowe-level windows apis are those Native win32 applications. Where you creat a message pump with the necessary WNDCLASSEX to represent/register the window message pump and message handler process. What you will deal with the win32 applications include the following.
RegisterClassEx, CreateWindowEx, GetMessage(), TranslateMesage(), and DispatchMessage(...).
to be able to use the Window API, you have to declare tons of Structure and PInvoke Method, while you can find help from the Pinvoke.Net.
First, we will introduce some of the win32/user32 functions and their relative structure definitions.