Skip to content

Instantly share code, notes, and snippets.

View lsiden's full-sized avatar

Lawrence Siden lsiden

View GitHub Profile
#!/usr/bin/python
import gi
import sys
from gi.repository import GObject
gi.require_version('Gst', '1.0')
from gi.repository import Gst
from gi.repository import GstController
from gi.repository import GLib
GObject.threads_init()
@lsiden
lsiden / gist:11ee113b0798e19a255e5a88d9c984e3
Created October 19, 2016 15:35
Output of 'vagrant provision'
==> moc-local2: Error: Execution of '/usr/local/rvm/bin/rvm install 2.3 ' returned 1: Searching for binary rubies, this might take some time.
==> moc-local2: Found remote file https://rvm_io.global.ssl.fastly.net/binaries/ubuntu/16.04/x86_64/ruby-2.3.0.tar.bz2
==> moc-local2: Checking requirements for ubuntu.
==> moc-local2: Installing requirements for ubuntu.
==> moc-local2: Updating system.........
==> moc-local2: Error running 'requirements_debian_update_system ruby-2.3.0',
==> moc-local2: showing last 15 lines of /usr/local/rvm/log/1476890187_ruby-2.3.0/update_system.log
==> moc-local2: ++ case "${TERM:-dumb}" in
==> moc-local2: ++ case "$1" in
==> moc-local2: ++ [[ -t 2 ]]
@lsiden
lsiden / stream.sh
Last active September 22, 2016 21:40
#!/bin/bash
infile=sample_videos/myvideo.mp4
GST_DEBUG=0 gst-launch-1.0 -v \
filesrc location=subtitles.srt ! subparse ! ov. \
filesrc location=$infile ! decodebin name=demuxer ! textoverlay name=ov ! x264enc ! mpegtsmux name=muxer \
demuxer. ! audioconvert ! audioresample ! avenc_mp2 ! muxer. \
muxer. ! hlssink \
playlist-root=/hls-test \
<head>
<link href="http://vjs.zencdn.net/5.11.6/video-js.css" rel="stylesheet">
<!--[if IE 8]>
<script src="http://vjs.zencdn.net/ie8/1.1.2/videojs-ie8.min.js"></script>
<![endif]-->
<script src="http://vjs.zencdn.net/5.11.6/video.js"></script>
<script src="videojs-contrib-hls.min.js"></script>
</head>
@lsiden
lsiden / gist:8310790
Created January 8, 2014 02:32
Here's a way to make a relation immutable that doesn't break.
# Prevent self.user from being changed
alias_method :old_user_assign, :user=
def user=(new_user)
if self.new_record?
old_user_assign new_user
else
logger.warn "Attempt to modify user of record, id=#{self.id} with user id=#{new_user.id}"
return false
end
@lsiden
lsiden / gist:8310536
Created January 8, 2014 02:10
A test that fails when this solution, http://stackoverflow.com/a/6456889/270511, is applied.
test "inverse of user.profiles" do
user = create :user
profile = create :profile, user: user
assert_equal profile, user.profiles.first, "profile == user.profiles.first"
end
@lsiden
lsiden / nf-iconbox
Created December 20, 2013 21:04
Custom Wordpress plugin to import into <mysite>/wp-admin/options-general.php?page=post-snippets/post-snippets.php&tab=snippets to match functionality of Inovado-theme "iconbox" shortcode. See http://themeforest.net/item/inovado-retina-responsive-multipurpose-theme/3810895 The initials "nf" stand for my client's http://company: thenewfoundry.com
a:1:{i:0;a:7:{s:5:"title";s:10:"nf-iconbox";s:4:"vars";s:13:"title,imgpath";s:9:"shortcode";b:1;s:3:"php";b:0;s:11:"wptexturize";b:0;s:7:"snippet";s:196:"<div class="iconbox">
<span class="nf-iconbox" style="background-image: url('{imgpath}'); background-repaeat: no-repeat; vertical-align: middle !important; "></span><br>
<h3>{title}</h3>
</div>";s:11:"description";s:75:"Insert a custom NewFoundry iconbox. Same functionality as Inovado iconbox.";}}
@lsiden
lsiden / demo.sql
Created July 20, 2012 13:06
Impossible WHERE noticed after reading const tables
-- MySQL dump 10.11
--
-- Host: localhost Database: demo
-- ------------------------------------------------------
-- Server version 5.0.96
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
# mount
rootfs on / type rootfs (ro,relatime)
tmpfs on /dev type tmpfs (rw,relatime,mode=755)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
none on /acct type cgroup (rw,relatime,cpuacct)
tmpfs on /mnt/asec type tmpfs (rw,relatime,mode=755,gid=1000)
tmpfs on /mnt/obb type tmpfs (rw,relatime,mode=755,gid=1000)
none on /dev/cpuctl type cgroup (rw,relatime,cpu)
@lsiden
lsiden / my-rvm-prompt
Created January 8, 2012 06:28
Wrapper for rvm-prompt that searches parent directories for files that tell we're in a Ruby project dir or sub-dir
#!/bin/bash
# Use this script instead of ~/.rvm/bin/rvm-prompt
# and the output of rvm-prompt will show up in your command prompt
# only if you are in a Ruby project directory.
# see http://stackoverflow.com/a/4264351/270511
# and http://unix.stackexchange.com/questions/13464/is-there-a-way-to-find-a-file-in-an-inverse-recursive-search