Skip to content

Instantly share code, notes, and snippets.

View MechanisM's full-sized avatar
💩

Eugene MechanisM MechanisM

💩
  • MechanisM
  • Vancouver, BC, Canada
View GitHub Profile
@MechanisM
MechanisM / ffmpeg-livestream-to-streaming-sites-vaapi-nvenc.md
Created November 6, 2019 00:08 — forked from Brainiarc7/ffmpeg-livestream-to-streaming-sites-vaapi-nvenc.md
ffmpeg livestreaming to youtube via Nvidia's NVENC and Intel's VAAPI on supported hardware

Streaming your Linux desktop to Youtube and Twitch via Nvidia's NVENC and VAAPI:

Considerations to take when live streaming:

The following best practice observations apply when using a hardware-based encoder for live streaming to any platform:

  1. Set the buffer size (-bufsize:v) equal to the target bitrate (-b:v). You want to ensure that you're encoding in CBR mode.

  2. Set up the encoders as shown:

#!/usr/bin/env python3
import redis
import xml.dom.minidom as minidom
def generate_placemark(doc, document, station):
"Generates a single place mark from a station"
placemark = doc.createElement('Placemark')
document.appendChild(placemark)
@MechanisM
MechanisM / workflows-in-django.md
Created February 17, 2018 20:11 — forked from Nagyman/workflows-in-django.md
Workflows in Django

Workflows (States) in Django

I'm going to cover a simple, but effective, utility for managing state and transitions (aka workflow). We often need to store the state (status) of a model and it should only be in one state at a time.

Common Software Uses

  • Publishing (Draft->Approved->Published->Expired->Deleted)
@MechanisM
MechanisM / postgres-notify-trigger.sql
Created February 13, 2018 02:43 — forked from bithavoc/postgres-notify-trigger.sql
I used this trigger to notify table changes via NOTIFY (migrating off RethinkDB)
CREATE OR REPLACE FUNCTION notify_trigger() RETURNS trigger AS $$
DECLARE
channel_name varchar DEFAULT (TG_TABLE_NAME || '_changes');
BEGIN
IF TG_OP = 'INSERT' THEN
PERFORM pg_notify(channel_name, '{"id": "' || NEW.id || '"}');
RETURN NEW;
END IF;
IF TG_OP = 'DELETE' THEN
PERFORM pg_notify(channel_name, '{"id": "' || OLD.id || '"}');
@MechanisM
MechanisM / howto.md
Created February 1, 2018 10:51 — forked from adamcharnock/howto.md
Kubernetes install on Ubuntu 17.10 via kubeadm

Kubernetes install on Ubuntu 17.10 via kubeadm

Initial setup

apt-get update
apt-get upgrade
apt-get install curl

# Check VXLAN exists
@MechanisM
MechanisM / meta-tags.md
Created September 28, 2017 10:13 — forked from jochemstoel/meta-tags.md
Complete List of HTML Meta Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta charset='UTF-8'>
<meta name='keywords' content='your, tags'>
<meta name='description' content='150 words'>
<meta name='subject' content='your website's subject'>
<meta name='copyright' content='company name'>

Keybase proof

I hereby claim:

  • I am mechanism on github.
  • I am mechanism (https://keybase.io/mechanism) on keybase.
  • I have a public key ASAYecgpXx82qwlmw9uXz9-8gMxbsMeinXffkuZbsTTXbAo

To claim this, I am signing this object:

@MechanisM
MechanisM / django-ajax-generated-template.html
Last active August 29, 2015 14:18
Django Ajax with CSRF for Polymer
<link rel="import" href="{{ STATIC_URL }}vendor/polymer/polymer.html">
<link rel="import" href="{{ STATIC_URL }}vendor/core-ajax/core-ajax.html">
<polymer-element name="django-ajax" extends="core-ajax">
<script>
Polymer({
ready: function() {
this.super();
this.headers = {
"X-CSRFToken": {{ csrf_token }},