Skip to content

Instantly share code, notes, and snippets.

View rchukh's full-sized avatar

Roman Chukh rchukh

  • Ukraine
  • 11:28 (UTC +03:00)
View GitHub Profile
@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(
@plembo
plembo / upnper4dont.md
Last active May 23, 2024 19:55
UPnP with EdgeRouter: Don't do it! Ubiquiti. ER-4.

Want to configure UPnP on EdgeRouter-4?

Don't do it!

Introduction

As a former sysadmin that once helped ride herd over around 1,000 servers, of which around 10% were Internet-facing, I've never been a fan of autoconfiguation when it comes to punching holes through the firewall. I've seen the tripwire logs, and it's sobering.

The Problem

So enabling UPnP on my EdgeRouter-4 wasn't something I had on the roadmap, but when I ran into difficulty getting DLNA to work on the default VLAN, I thought it was worth looking into (never mind that, as I later learned, having UPnP turned on wasn't going make a bit of difference on my local network: another reason that mastering theory should always come before practice).

@HaloFour
HaloFour / StreamingJsonArrayExtractor.java
Created April 23, 2020 14:25
Reactive JSON Array Extractor
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.function.Function;
import java.util.function.Supplier;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonPointer;
@Snarp
Snarp / google-docs-copy.js
Last active June 13, 2024 13:00
Script to allow copying from a protected Google Doc
/*
<https://stackoverflow.com/questions/40296831/is-it-possible-to-force-a-copy-of-a-protected-google-doc>
NOTE - 2021-05-24
-----------------
The script below isn't the fastest way to copy-and-paste from a protected
Google Doc. Before trying it, I'd suggest following MikoFrosty's advice from
the comments:
@dbaston
dbaston / single-precision-points.sql
Last active April 15, 2022 08:00
Using single-precision points in PostGIS
-- create point table using single-precision coordinates
CREATE TABLE pts (
point_id serial,
x real,
y real
);
-- create a view that converts these into a PostGIS geometry
CREATE VIEW pts_view AS
SELECT point_id, ST_SetSRID(ST_MakePoint(x, y), 4326) AS geom FROM pts;
@garethahealy
garethahealy / jcmd.sh
Created January 5, 2017 18:03
java heapdump for docker
#!/bin/bash
docker exec $1 ps -deaf
echo -n "PID for Java: "
read pid
docker exec $1 jcmd $pid GC.heap_dump /tmp/docker.hprof
docker cp $1:/tmp/docker.hprof .
docker exec $1 rm /tmp/docker.hprof
@cadurosar
cadurosar / test_notebook.ipynb
Last active August 4, 2023 22:19
A interactive ipython notebook for: Keras plays catch - https://gist.github.com/EderSantana/c7222daa328f0e885093
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@EderSantana
EderSantana / CATCH_Keras_RL.md
Last active October 16, 2023 08:32
Keras plays catch - a single file Reinforcement Learning example
@ueshin
ueshin / sparkmeetup.md
Created September 8, 2014 08:49
Spark SQL samples for Spark Meetup
// Create Vertices
val users: RDD[(VertexId, (String, String))] = sc.parallelize(Array(
//Alice her bank is HSBC, she has APPL shares
(1000L, ("human", "Alice")),
(1001L, ("bank", "HSBC")),
(1002L, ("shares", "APPL")),
//Transaction vertices