Skip to content

Instantly share code, notes, and snippets.

View tobischw's full-sized avatar

Tobi Schweiger tobischw

  • Square Inc.
  • 00:27 (UTC -05:00)
View GitHub Profile
@Martini024
Martini024 / VideoHelper.swift
Last active June 28, 2024 23:17
SwiftUI: Rewrite iOS Photos Video Scrubber
import Foundation
import AVKit
class VideoHelper {
static func getThumbnail(from player: AVPlayer, at time: CMTime) -> CGImage? {
do {
guard let currentItem = player.currentItem else { return nil }
let asset = currentItem.asset
let imgGenerator = AVAssetImageGenerator(asset: asset)
using System;
using System.Collections.Generic;
using System.Linq;
//A* Search Pathfinding Example from : https://dotnetcoretutorials.com/2020/07/25/a-search-pathfinding-algorithm-in-c/
namespace PathfindingExample
{
class Program
{
static void Main(string[] args)
@xtabbas
xtabbas / SnapCarousel.swift
Created May 10, 2020 18:13
A carousel that snap items in place build on top of SwiftUI
//
// SnapCarousel.swift
// prototype5
//
// Created by xtabbas on 5/7/20.
// Copyright © 2020 xtadevs. All rights reserved.
//
import SwiftUI
protocol Pokemon {
associatedtype PokemonType
var name: String { get }
var type: PokemonType { get }
}
struct Electric {
// something
}
// Three different lexer implementations. First a "consume everything" lexer, then a "lazy" lexer (that is, an iterator), then a lazy lexer without explicit state.
enum Token {
case heading(level: Int)
case star
case text(String)
}
import Foundation
@josephbk117
josephbk117 / WhiteNoise.shader
Last active September 18, 2022 03:37
White noise ( grain filter ) shader in unity
Shader "BitShiftProductions/Noises"
{
Properties
{
_MainTex("Texture", 2D)="white"
_NoiseScale("Noise Scale",Float) = 5.0
_Strength("Noise Strength",Float) = 1.0
}
SubShader
{
@jboner
jboner / OrderManagement.java
Created November 10, 2017 09:06
Demo of an Event-driven Architecture in Akka and Java. Show-casing Events-first DDD, Event Sourced Aggregates, Process Manager, etc.
package sample.eventdriven.java;
import akka.actor.*;
import akka.persistence.AbstractPersistentActor;
import scala.concurrent.duration.Duration;
import java.io.Serializable;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
@cprovatas
cprovatas / BlockBasedSelector.h
Last active June 9, 2024 13:08
Block-Based Selectors in Swift
//
// BlockBasedSelector.h
//
// Created by Charlton Provatas on 11/2/17.
// Copyright © 2017 CharltonProvatas. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface BlockBasedSelector : NSObject
@Agarunov
Agarunov / type_erasure.swift
Last active November 10, 2021 15:12
Swift Type Erasure example
//: Playground - noun: a place where people can play
protocol ObjectMapper {
associatedtype SourceType
associatedtype ResultType
func map(_ object: SourceType) -> ResultType
@jschomay
jschomay / NestedList.elm
Created March 21, 2017 03:38
Nested List example in Elm
import Html exposing (text)
import List
{- Challenge: flatten an array of arbitrarily nested arrays of integers into a flat array of integers. e.g. [[1,2,[3]],4] -> [1,2,3,4].
(This is a little tricky in Elm because the type system does not allow for lists with different element types. So we have to make a whole new data structure...)
-}