Skip to content

Instantly share code, notes, and snippets.

View vookimedlo's full-sized avatar

Michal Duda vookimedlo

View GitHub Profile
//
// Copyright (c) 2016, 2018 Nikolai Ruhe. All rights reserved.
//
import Foundation
public extension FileManager {
/// Calculate the allocated size of a directory and all its contents on the volume.
@AkdM
AkdM / Edit_Repack_ISO_tutorial.md
Last active June 15, 2024 14:40
Edit and repack .iso bootable image

On Linux

Installing mkisofs

apt-get install mkisofs

Editing ISO image

mkdir /tmp/custom_iso

@mosen
mosen / Share.swift
Created March 6, 2018 04:55
Convenient swift-like wrapper over NetFS smb mounting
import Foundation
import NetFS
enum ShareMountError: Error {
case InvalidURL
case MountpointInaccessible
case InvalidMountOptions
}
@HertzDevil
HertzDevil / enum_traits.hpp
Last active December 25, 2023 06:31
safer enums in c++
#pragma once
#include <type_traits>
#include <limits>
// The default enumeration category. Conversion is equivalent to static_cast.
// Unspecialized enumeration traits use this category.
struct enum_default { };
// The standard-layout enumeration category. Values outside the given range are
@hfossli
hfossli / SHA256-Bridging-Header.h
Last active July 1, 2024 02:01
AES 256 in swift 4 with CommonCrypto
#import <CommonCrypto/CommonCrypto.h>
@nahuelDeveloper
nahuelDeveloper / CalculatorView.swift
Created October 4, 2017 12:49 — forked from natecook1000/CalculatorView.swift
An IBInspectable Calculator Construction Set
// CalculatorView.swift
// as seen in http://nshipster.com/ibinspectable-ibdesignable/
//
// (c) 2015 Nate Cook, licensed under the MIT license
import UIKit
/// The alignment for drawing an String inside a bounding rectangle.
enum NCStringAlignment {
case LeftTop
@brennanMKE
brennanMKE / BytesPlayground.swift
Last active December 16, 2023 18:30
Copy bytes from Data with Swift
import Foundation
let size = MemoryLayout<Int16>.stride
let data = Data(bytes: [1, 0, 2, 0, 3, 0]) // little endian for 16-bit values
let int16s = data.withUnsafeBytes { (bytes: UnsafePointer<Int16>) in
Array(UnsafeBufferPointer(start: bytes, count: data.count / size))
}
let length = data.count * MemoryLayout<Int16>.stride
@Nirma
Nirma / FTPUpload.swift
Last active December 30, 2023 02:11
Upload a file via FTP on iOS or macOS
import Foundation
import CFNetwork
public class FTPUpload {
fileprivate let ftpBaseUrl: String
fileprivate let directoryPath: String
fileprivate let username: String
fileprivate let password: String
@maxivak
maxivak / readme.md
Last active November 21, 2022 21:16
Multiple networks in LXC container

Network for LXC container

Host device as bridge

  • persisted in host's /etc/network/interfaces the container's veth virtual ethernet interface can share the network link on the physical interface of the host (eth0). So the container resides on the same ethernet segment and talks to the same dhcp server as the host does.

Additonal bridge device

  • setup manually with brctl
@vitorio
vitorio / osx-libmagic-homedir.md
Last active February 14, 2019 21:19
Compiling libmagic and libmagic python bindings natively on OS X within your home directory

These instructions compile a native OS X version of libmagic and the libmagic python binding, which use the system magic database, that live in your home directory, and which cannot be moved around, but which should always be discoverable by applications.

Assumes OS X with Xcode or Xcode command-line tools, not macports or homebrew

To install Xcode command-line tools in recent versions of OS X, open Terminal, type xcode-select --install and click "Install"

Older versions of OS X may need to manually download disk images of older versions of Xcode and/or the Xcode command-line tools, as various certificates may have expired (e.g. 10.7.4 requires a manual install from the Xcode 4.6.2 command-line tools image)

Download Apple's latest modified file 5.04 (used in 10.7+) from http://opensource.apple.com/tarballs/file/file-47.tar.gz