Skip to content

Instantly share code, notes, and snippets.

View vin047's full-sized avatar

Vinoth Ramiah vin047

View GitHub Profile
@steipete
steipete / TempDir.swift
Created October 25, 2018 09:17
Based on https://nshipster.com/temporary-files/ I ran some experiments with the recommended replacement API for NSTemporaryDirectory(). It's not straightforward.
// tl;dr: FileManager.default.url(for:in:appropriateFor:create:) has unexpected behavior in Simulator and creates temporary folders outside the tmp/ directory.
let tmpDirClassic = NSTemporaryDirectory()
print("tmpDirClassic: \(tmpDirClassic)")
// This is the same code, just syntax sugar for NSTemporaryDirectory()
// https://github.com/apple/swift-corelibs-foundation/blob/master/Foundation/FileManager.swift#L1420-L1422
let tmpDirClassicNewShim = FileManager.default.temporaryDirectory
print("tmpDirClassicNewShim: \(tmpDirClassicNewShim)")
// Simulator: /Users/steipete/Library/Developer/CoreSimulator/Devices/31C05637-B9C9-482C-A6CE-D063A7CECF64/data/Containers/Data/Application/A68D11A4-88BA-4FCF-A8B1-D102945D0740/tmp/
@pazdera
pazdera / adapter.cpp
Created August 15, 2011 07:37
Example of `adapter' design pattern in C++
/*
* Example of `adapter' design pattern
* Copyright (C) 2011 Radek Pazdera
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,