Skip to content

Instantly share code, notes, and snippets.

View m4p's full-sized avatar

Martin Pittenauer m4p

View GitHub Profile
@mwahlig
mwahlig / ZipManyPublisher.swift
Last active February 17, 2024 02:15
a Combine Publisher that allows for zipping an array of publishers while maintaining their index
extension Publishers {
private struct IndexedResult<T> {
let index: Int
let result: T
}
private struct IndexedPublisher<Upstream>: Publisher where Upstream: Publisher {
typealias Output = IndexedResult<Upstream.Output>
typealias Failure = Upstream.Failure
@smosko
smosko / OSLog+Extensions.swift
Last active December 26, 2022 07:54
Unified Logging Wrapper
import Foundation
@_exported import os.log
public extension OSLog {
convenience init(_ bundle: Bundle = .main, category: String? = nil) {
self.init(subsystem: bundle.bundleIdentifier ?? "default", category: category ?? "default")
}
convenience init(_ aClass: AnyClass, category: String? = nil) {
@epologee
epologee / Binary STL parser.swift
Last active December 10, 2024 08:43
Create SceneKit geometry from Binary STL files in Swift 4
import Foundation
import SceneKit
public enum BinarySTLParser {
public enum STLError: Error {
case fileTooSmall(size: Int)
case unexpectedFileSize(expected: Int, actual: Int)
case triangleCountMismatch(diff: Int)
}
@siemensikkema
siemensikkema / fixcodeproj.rb
Last active April 15, 2021 14:06
Post processing script for generated vapor Xcode project
#!/usr/bin/env ruby
require 'xcodeproj'
project_path = ARGV[0]
project = Xcodeproj::Project.open(project_path)
project.targets.each do |target|
# suppress warnings
if [
"Configs",
enum DateStride {
case year(Int)
case month(Int)
case day(Int)
var component: Calendar.Component {
switch self {
case .year(_):
return .year
@Pyrolr
Pyrolr / ViewController.swift
Last active May 2, 2020 14:33
AVPlayerController overlay custom view
class ViewController: UIViewController {
let AVPlayerVC = AVPlayerViewController()
var commmentQueuePlayer = AVQueuePlayer()
var OverlayView = UIView()
var prevItem:AVPlayerItem?
override func viewDidLoad() {
super.viewDidLoad()
setupCustomPlayer()
@dropmeaword
dropmeaword / browser_history.md
Last active March 30, 2025 06:03
Playing around with Chrome's history

Browser histories

Unless you are using Safari on OSX, most browsers will have some kind of free plugin that you can use to export the browser's history. So that's probably the easiest way. The harder way, which seems to be what Safari wants is a bit more hacky but it will also work for other browsers. Turns out that most of them, including Safari, have their history saved in some kind of sqlite database file somewhere in your home directory.

The OSX Finder cheats a little bit and doesn't show us all the files that actually exist on our drive. It tries to protect us from ourselves by hiding some system and application-specific files. You can work around this by either using the terminal (my preferred method) or by using the Cmd+Shft+G in Finder.

Finder

Once you locate the file containing the browser's history, copy it to make a backup just in case we screw up.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function, unicode_literals
import sys
import fileinput
import time
import math
@monkeydom
monkeydom / swiftc.sh
Last active October 24, 2015 23:50
Script to be used in a hashbang to conditionally compile and then run the swift script referenced. usage #!/usr/bin/env swiftc.sh in your swift file, and put in path
#!/bin/sh
SWIFT=$(/usr/bin/env xcrun -f swift)
SCRIPTPATH=$1
COMPILEDPATH="$SCRIPTPATH.o"
SDKPATH=$(/usr/bin/env xcrun --show-sdk-path --sdk macosx)
#compile if necessary
//
// ViewController.m
// AVPlayerCaching
//
// Created by Anurag Mishra on 5/19/14.
// Sample code to demonstrate how to cache a remote audio file while streaming it with AVPlayer
//
#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>