Skip to content

Instantly share code, notes, and snippets.

View matthiasg's full-sized avatar

matthiasg matthiasg

View GitHub Profile
@matthiasg
matthiasg / GStreamer.md
Created February 25, 2020 08:40
GStreamer Notes for WebRTC with Windows Camera Source
> gst-device-monitor-1.0.exe
   
   
   ...
    
Device found:

	name  : 00 Pro Capture AIO
	class : Video/Source
@matthiasg
matthiasg / gist:1b55cb46786fd241931083f0280b40c8
Created November 15, 2019 08:17 — forked from chanks/gist:7585810
Turning PostgreSQL into a queue serving 10,000 jobs per second

Turning PostgreSQL into a queue serving 10,000 jobs per second

RDBMS-based job queues have been criticized recently for being unable to handle heavy loads. And they deserve it, to some extent, because the queries used to safely lock a job have been pretty hairy. SELECT FOR UPDATE followed by an UPDATE works fine at first, but then you add more workers, and each is trying to SELECT FOR UPDATE the same row (and maybe throwing NOWAIT in there, then catching the errors and retrying), and things slow down.

On top of that, they have to actually update the row to mark it as locked, so the rest of your workers are sitting there waiting while one of them propagates its lock to disk (and the disks of however many servers you're replicating to). QueueClassic got some mileage out of the novel idea of randomly picking a row near the front of the queue to lock, but I can't still seem to get more than an an extra few hundred jobs per second out of it under heavy load.

So, many developers have started going straight t

@matthiasg
matthiasg / small-arc.sh
Created August 15, 2019 12:21 — forked from RantyDave/small-arc.sh
Limit the SmartOS (and Solaris?) ARC to a maximum of 256Mb. Works live, no reboot needed :)
#!/bin/bash
echo "arc_stats::print -a arcstat_p.value.ui64" | mdb -kw > value.ui64
ui64=$(cat value.ui64)
echo "${ui64:0:16}/Z 0x10000000" | mdb -kw
echo "arc_stats::print -a arcstat_c.value.ui64" | mdb -kw > value.ui64
ui64=$(cat value.ui64)
echo "${ui64:0:16}/Z 0x10000000" | mdb -kw
echo "arc_stats::print -a arcstat_c_max.value.ui64" | mdb -kw > value.ui64
ui64=$(cat value.ui64)
echo "${ui64:0:16}/Z 0x10000000" | mdb -kw
@matthiasg
matthiasg / small-arc.sh
Created August 15, 2019 12:21 — forked from RantyDave/small-arc.sh
Limit the SmartOS (and Solaris?) ARC to a maximum of 256Mb. Works live, no reboot needed :)
#!/bin/bash
echo "arc_stats::print -a arcstat_p.value.ui64" | mdb -kw > value.ui64
ui64=$(cat value.ui64)
echo "${ui64:0:16}/Z 0x10000000" | mdb -kw
echo "arc_stats::print -a arcstat_c.value.ui64" | mdb -kw > value.ui64
ui64=$(cat value.ui64)
echo "${ui64:0:16}/Z 0x10000000" | mdb -kw
echo "arc_stats::print -a arcstat_c_max.value.ui64" | mdb -kw > value.ui64
ui64=$(cat value.ui64)
echo "${ui64:0:16}/Z 0x10000000" | mdb -kw
@matthiasg
matthiasg / insert-signature-in-pdf.md
Created August 3, 2019 14:14 — forked from chrpinedo/insert-signature-in-pdf.md
How to insert your signature in a PDF file by using PDFtk

How to insert your signature in a PDF file by using PDFtk

Your signature in all the sheets

  1. convert the signature image to PDF file
convert firma.png firma.pdf
@matthiasg
matthiasg / insert-signature-in-pdf.md
Created August 3, 2019 14:14 — forked from chrpinedo/insert-signature-in-pdf.md
How to insert your signature in a PDF file by using PDFtk

How to insert your signature in a PDF file by using PDFtk

Your signature in all the sheets

  1. convert the signature image to PDF file
convert firma.png firma.pdf
@matthiasg
matthiasg / keybase.md
Created April 16, 2019 07:55
keybase

Keybase proof

I hereby claim:

  • I am matthiasg on github.
  • I am matthiasg (https://keybase.io/matthiasg) on keybase.
  • I have a public key ASCFZyamXEDIBolEyLgrbvdB36vrCF5jFywJG0tmR1hdCAo

To claim this, I am signing this object:

@matthiasg
matthiasg / playground.rs
Last active March 21, 2019 10:42 — forked from rust-play/playground.rs
Code shared from the Rust Playground
struct MyType {
value: u32
}
impl MyType {
fn new() -> MyType {
MyType {
value: 1
}
}
@matthiasg
matthiasg / sha256.js
Created March 13, 2019 07:15
SHA256
// From: https://github.com/Hartland/GPL-CPU-Miner/blob/master/sha2.c
if ("undefined" == typeof vnet) {
vnet = new Array();
}
if ("undefined" == typeof vnet.crypt) {
vnet.crypt = new Array();
}
@matthiasg
matthiasg / gist:3cefcb5e6d51ba66995e3011b0175a32
Created February 25, 2019 15:50 — forked from xen0l/gist:732fb7a6bb50ffbf0ba9
How to make QEMU guest-agent work on SmartOS
[root@smartos ~]# UUID="afe2f552-4a35-4c44-8855-a9bac10f27d2"
[root@smartos ~]# vmadm update ${UUID} qemu_extra_opts="-chardev socket,path=/tmp/vm.qga,server,nowait,id=qga0 -device virtio-serial -device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0"
Successfully updated VM afe2f552-4a35-4c44-8855-a9bac10f27d2
[root@smartos ~]# vmadm boot ${UUID}
Successfully started VM afe2f552-4a35-4c44-8855-a9bac10f27d2
[root@smartos ~]# sleep 60 # Machine needs to boot up
[root@smartos ~]# echo '{"execute": "guest-ping" }' | socat stdio unix-connect:/zones/${UUID}/root/tmp/vm.qga # Is GA alive?
{"return": {}}
[root@smartos ~]# echo '{"execute": "guest-info" }' | socat stdio unix-connect:/zones/${UUID}/root/tmp/vm.qga # show information about GA
{"return": {"version": "0.12.1", "supported_commands": [{"enabled": true, "name": "guest-set-vcpus"}, {"enabled": true, "name": "guest-get-vcpus"}, {"enabled": true, "name": "guest-network-get-interfaces"}, {"enabled": true, "name": "guest-suspend-hybrid"}, {"enabled": tru