Skip to content

Instantly share code, notes, and snippets.

IamNaN / webcam
Created March 3, 2023 06:11
Ruby script to reset and start a DSLR or Mirrorless camera as a webcam using gphoto2, v4l2loopback, and ffmpeg
#!/usr/bin/env ruby
system("sudo modprobe -r v4l2loopback")
system("pkill gphoto")
system("sudo modprobe v4l2loopback exclusive_caps=1 max_buffers=2")
system("gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video0")
IamNaN / .gitignore
Last active May 12, 2019 21:17
global .gitignore
# place in ~/.gitignore
# configure with `git config --global core.excludesfile ~/.gitignore`
IamNaN / gist:e6cd2e9611c19f7933fc
Created April 14, 2015 04:32
Hack to get bootstrap datetimepicker to accept US formatted date/time
$('form').submit (event) ->
$(this).find('.datetime').each ->
$(this).val moment(new Date($(this).val()))
IamNaN / readme
Created November 27, 2012 23:12
Regex to parse HTML attribute/value pairs.
This regex parses attributes from their values such as those in HTML elements. It returns the attribute
names and their values even when the quotes are escaped, nested, or omitted.
The following are examples attribute/value pairs that are properly divided:
a="a" b="b b" c='c' d=1 e="escaped \" quotes" f="'nested quotes'" g = 'gaps' h="multiple spaces"
The attribute name will be in match position 0, while the value will be in either position 4 or 5
depending on whether or not the value is quoted.
IamNaN / gist:3682443
Created September 9, 2012 03:42
command line output from radiant's rake seed task
webuser@cms-site:~/cmshome/current$ bundle exec rake production db:bootstrap
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /home/webuser/cmshome/shared/bundle/ruby/1.9.1/gems/rails-2.3.14/lib/rails/gem_dependency.rb:21.
This task will destroy any data in the database. Are you sure you want to
continue? [yn] y
-- drop_table("schema_migrations")
-> 0.0354s
-- drop_table("config")
-> 0.0029s
IamNaN / _spec.rb
Created April 24, 2012 22:32
Unexpected results with rspec and factory girl
require 'spec_helper'
describe Article do
it 'can set the privacy' do
article = create(:article)
article.comments.first.privacy.should eq 'low' #Pass
comment = article.comments.first
comment.privacy.should eq 'low' #Pass
<script type="text/javascript">
window.onload = function(){ setTimeout(function() { window.scrollTo(0,0); },500); };
window.onorientationchange = function(){ setTimeout( function() { window.scrollTo(0,0); },100); };
function load() { if (navigator.userAgent.match(/OS 5(_\d)+ like Mac OS X/i)) { document.body.className+=" ios5" }}
IamNaN / gist:1449060
Created December 8, 2011 22:47
require 'simplecov'
require 'rubygems'
require 'spork'
Spork.prefork do
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)