Skip to content

Instantly share code, notes, and snippets.

//
// Created by Gregory McQuillan on 12/23/16.
// Copyright (c) 2016 One Big Function. All rights reserved.
//
import WebRTC
import Foundation
class ARDSDPUtils {
/**
// MARK: - AVCaptureVideoDataOutputSampleBufferDelegate extension {{{
extension CtsVideoCallView: AVCaptureVideoDataOutputSampleBufferDelegate {
func captureOutput(_ captureOutput: AVCaptureOutput!,
didOutputSampleBuffer sampleBuffer: CMSampleBuffer!,
from: AVCaptureConnection!) {
// get image size for preview and resize preview view accordingly
let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer)
let attachments = CMCopyDictionaryOfAttachments(kCFAllocatorDefault,
sampleBuffer, kCMAttachmentMode_ShouldPropagate) as! Dictionary
let ciImage = CIImage(cvPixelBuffer: imageBuffer, options: attachments)
var videoSources: [CtsVideoSource] {
var sources = [CtsVideoSource]()
for lv in left {
// for each left video
if let source = lv.videoSource {
sources.append(source)
}
}
for rv in right {
// MARK: - AVCaptureVideoDataOutputSampleBufferDelegate extension {{{
extension CtsVideoCallView: AVCaptureVideoDataOutputSampleBufferDelegate {
func captureOutput(_ captureOutput: AVCaptureOutput!,
didOutputSampleBuffer sampleBuffer: CMSampleBuffer!,
from: AVCaptureConnection!) {
// get image size for preview and resize preview view accordingly
let pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer)
let attachmentMode = CMAttachmentMode(kCMAttachmentMode_ShouldPropagate)
let attachments = CMCopyDictionaryOfAttachments(kCFAllocatorDefault, sampleBuffer, attachmentMode)
let ciImage:CIImage = CIImage(cvPixelBuffer: pixelBuffer!, options: attachments as! [String : Any]?)
pathadd() {
new_path=$1
if [[ -z "$TMUX" ]]; then
if [[ -d "$new_path" ]]; then
if [[ $PATH =~ $new_path ]]; then
#echo -e "pathadd: not adding $new_path to \$PATH".
else
export -U PATH=$new_path:$PATH
fi
fi
@objc(User)
final class User: NSObject, NSCoding {
let userId: Int
var email: String?
let name: String
var recentGames: [Int]?
/// nscoding keys
private static let ID_KEY = "id"
@hk0i
hk0i / TestMaps.cs
Last active August 2, 2023 04:06
testing generics, interfaces and state machines
using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine;
public class TestMaps
{
[Test]
public void CyclicDependency()
{
var machine = new FakeMachine<FakeStates, IFakeState>();
@hk0i
hk0i / Inventory.cs
Created August 10, 2023 18:53
inventory class example
using System.Collections.Generic;
using UnityEngine;
namespace Shaninja.Scripts {
public interface IInventory
{
void AddCoin();
void SetTotalCoins(int total);
void Reset();