Skip to content

Instantly share code, notes, and snippets.

View tylercubell's full-sized avatar

Tyler tylercubell

View GitHub Profile
#!/bin/bash
# Backup MySQL database using dotenv file
#
# Example:
# ./backup_database.sh /path_to_project/.env
#
# Result:
# Schema-only and data-only .sql files
SELECT b1.bID as id,
u.uID as post_author,
b1.bDateAdded as post_date,
CONVERT_TZ(b1.bDateAdded,'-05:00','+00:00') as post_date_gmt,
b2.content as post_content,
c2.cvName as post_title,
c2.cvDescription as post_excerpt,
IF(b1.bIsActive = 1,'publish','draft') as post_status,
'open' as comment_status,
'open' as ping_status,
import os, subprocess
# Convert from ANSI (Windows-1251) to UTF-8 using iconv.
# http://gnuwin32.sourceforge.net/packages/libiconv.htm
file = "your_file_here"
command = ["C:\\Program Files (x86)\\GnuWin32\\bin\\iconv.exe",
"-f cp1251", # Could also be cp1252 or other encoding types.
"-t utf-8",
'"' + file + '"']
import os, subprocess
# Remove null characters.
# http://gnuwin32.sourceforge.net/packages/coreutils.htm
file = "your_file_here"
command = ["C:\\Program Files (x86)\\GnuWin32\\bin\\tr.exe",
"-d \'\\000\'"]
with open(file, "r") as original, open(file + ".new", "w", encoding="utf-8") as modified:
@tylercubell
tylercubell / dynamic_switching.py
Created February 4, 2019 19:02
GStreamer Python Dynamic Switching
import gi
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst
from threading import Thread, Event
GObject.threads_init()
Gst.init(None)
class Main:
def __init__(self):
@tylercubell
tylercubell / infinite_loop.py
Created February 4, 2019 21:57
GStreamer Python Infinite Loop
import gi
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst
import os
Gst.init(None)
mainloop = GObject.MainLoop()
# Short way:
# pipeline = Gst.parse_launch("filesrc name=filesource ! decodebin ! autovideosink")
@tylercubell
tylercubell / infinite_loop_version_2.py
Created February 4, 2019 22:14
GStreamer Infinite Loop Version 2
import gi
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst
import os
Gst.init(None)
# Short way:
# pipeline = Gst.parse_launch("filesrc name=filesource ! decodebin ! autovideosink")
# pipeline.get_by_name("filesource").set_property("location", "background.mov")
@tylercubell
tylercubell / playbin_custom_video-sink.py
Last active November 19, 2023 13:37
GStreamer Python Playbin Custom Video-sink
import gi
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst
Gst.init(None)
class Main:
def __init__(self):
self.pipeline = Gst.Pipeline.new("pipeline")
self.bus = self.pipeline.get_bus()
@tylercubell
tylercubell / custom_message.py
Created February 7, 2019 05:34
GStreamer Python Custom Message
import gi
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst
from threading import Thread, Event
Gst.init(None)
class Main:
def __init__(self):
self.pipeline = Gst.Pipeline.new("pipeline")
@tylercubell
tylercubell / add_remove_source_dynamically.py
Created February 7, 2019 20:08
GStreamer Python Add/Remove Source Dynamically
import gi
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst
from threading import Thread, Event
Gst.init(None)
class Main:
def __init__(self):
self.pipeline = Gst.Pipeline.new("pipeline")