Skip to content

Instantly share code, notes, and snippets.

@xaphod
xaphod / VideoWriter.swift
Created March 10, 2021 15:51
Creating a video from UIImage (or SampleBuffers from camera)
import UIKit
import AVFoundation
class VideoWriter {
fileprivate var writer: AVAssetWriter
fileprivate var writerInput: AVAssetWriterInput
fileprivate var pixelBufferAdaptor: AVAssetWriterInputPixelBufferAdaptor
fileprivate let queue: DispatchQueue
static var ciContext = CIContext.init() // we reuse a single context for performance reasons
@RedBeard0531
RedBeard0531 / functions.js
Created February 22, 2012 20:13
Min, Max, Sum, Count, Avg, and Std deviation using MongoDB MapReduce
// derived from http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Parallel_algorithm
function map() {
emit(1, // Or put a GROUP BY key here
{sum: this.value, // the field you want stats for
min: this.value,
max: this.value,
count:1,
diff: 0, // M2,n: sum((val-mean)^2)
});
Given /^I visit subdomain "(.+)"$/ do |sub|
#host! "#{sub}.example.com" #for webrat
Capybara.default_host = "#{sub}.example.com" #for Rack::Test
Capybara.app_host = "http://#{sub}.example.com:9887" if Capybara.current_driver == :culerity
################################################################################
# As far as I know, you have to put all the {sub}.example.com entries that you're
# using in your /etc/hosts file for the Culerity tests. This didn't seem to be
# required for Rack::Test
################################################################################