Skip to content

Instantly share code, notes, and snippets.

View brsnik's full-sized avatar

Boris Nikk brsnik

  • Skopje, MK
  • 06:51 (UTC +02:00)
View GitHub Profile
create extension if not exists pgcrypto;
create or replace function uuid_generate_v7()
returns uuid
as $$
declare
output bytea;
unixts bytea = e'\\000\\000\\000\\000\\000\\000\\000\\000\\000';
timestamp timestamptz;
unix_time bigint;
@kjmph
kjmph / A_UUID_v7_for_Postgres.sql
Last active June 1, 2024 14:09
Postgres PL/pgSQL function for UUID v7 and a bonus custom UUID v8 to support microsecond precision as well. Read more here: https://datatracker.ietf.org/doc/draft-peabody-dispatch-new-uuid-format/
-- Based off IETF draft, https://datatracker.ietf.org/doc/draft-peabody-dispatch-new-uuid-format/
create or replace function uuid_generate_v7()
returns uuid
as $$
begin
-- use random v4 uuid as starting point (which has the same variant we need)
-- then overlay timestamp
-- then set version 7 by flipping the 2 and 1 bit in the version 4 string
return encode(
@dunderrrrrr
dunderrrrrr / GeoIP Block NGINX Ubuntu 20.04.md
Created April 19, 2021 08:28
Allow or block GeoIP in Nginx on Ubuntu 20.04

GeoIP Block NGINX Ubuntu 20.04

Block or filter IPs based on location in Nginx (tested on 1.18.0) on Ubuntu 20.04.

Install Nginx modules

To make use of the geographical filtering, we must first install the Nginx GeoIP module as well as the GeoIP database containing the mappings between visitors’ IP addresses and their respective countries. To do so, let’s execute:

$ sudo apt install libnginx-mod-http-geoip geoip-database
#!/usr/sbin/nft -f
#
# This config was adapted from various sources.
#
# Use at your own risk. Learn what each rule does
# prior to implementing in your environment.
#
flush ruleset
import React from 'react';
class Parent extends React.Component{
constructor(props){
super(props);
this.state = {
data: null
}
}
import React from 'react';
function Parent(){
const data = 'Data from parent';
return(
<div>
<Child dataParentToChild = {data}/>
</div>
)
}
@Mefistophell
Mefistophell / RUST.MD
Last active May 23, 2024 09:11
How to Compile a Rust Program on Mac for Windows

Question: I want to compile my Rust source code for the Windows platform but I use macOS.

Solution:

  1. Install target mingw-w64: brew install mingw-w64
  2. Add target to rustup: rustup target add x86_64-pc-windows-gnu
  3. Create .cargo/config
  4. Add the instructions below to .cargo/config
[target.x86_64-pc-windows-gnu]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>HKAtrialFibrillationDetectionOnboardingCompleted</key>
<integer>1</integer>
<key>HKElectrocardiogramOnboardingCompleted</key>
<integer>3</integer>
</dict>
</plist>
@mjm918
mjm918 / client.py
Created December 15, 2018 09:56
Python socket programming AES CBC encryption
import socket
import os
import threading
import hashlib
from Crypto import Random
import Crypto.Cipher.AES as AES
from Crypto.PublicKey import RSA
import signal
from lazyme.string import color_print
@pedrouid
pedrouid / webcrypto-examples.md
Created December 15, 2018 01:07
Web Cryptography API Examples