Skip to content

Instantly share code, notes, and snippets.

@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();
@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>();
@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"
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
// 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]?)
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 imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer)
let attachments = CMCopyDictionaryOfAttachments(kCFAllocatorDefault,
sampleBuffer, kCMAttachmentMode_ShouldPropagate) as! Dictionary
let ciImage = CIImage(cvPixelBuffer: imageBuffer, options: attachments)
//
// Created by Gregory McQuillan on 12/23/16.
// Copyright (c) 2016 One Big Function. All rights reserved.
//
import WebRTC
import Foundation
class ARDSDPUtils {
/**
/*
* Copyright 2015 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/**
* Promise style method
*/
- (void)animateUi
{
const CGFloat valDestStatsBottom = self.conStatsBottomSpacing.constant;
const CGFloat valDestLeftArrowTrailing = self.conLeftArrowTrailing.constant;
const CGFloat valDestRightArrowLeading = self.conRightArrowLeading.constant;