Skip to content

Instantly share code, notes, and snippets.

View vookimedlo's full-sized avatar

Michal Duda vookimedlo

View GitHub Profile
@ktsaou
ktsaou / systemd-journal-self-signed-certs.sh
Last active May 11, 2025 21:36
systemd-journal-remote/upload self-signed certificates management script
#!/usr/bin/env bash
# The directory to save the generated certificates (and everything about this certificate authority).
# This is only used on the node generating the certificates (usually on the journals server).
DIR="/etc/ssl/systemd-journal-remote"
# The journals centralization server name (the CN of the server certificate).
SERVER="server-hostname"
# All the DNS names or IPs this server is reachable at (the certificate will include them).
@EricRabil
EricRabil / XCTHarness.swift
Last active August 1, 2024 08:32
XCTest doing absolutely nothing? Lack of documentation driving you insane? Avoiding a DTS ticket? Here's a Swift class that forcibly bootstraps XCTest when running inside of a test host and XCTest is not starting itself.
public class XCTHarness {
private typealias XCTestMainType = @convention(c) (_ something: AnyObject?) -> ()
private static func dlsymcast<T>(_ handle: UnsafeMutableRawPointer!, _ symbol: UnsafePointer<CChar>) -> T! {
dlsym(handle, symbol).map {
if T.self is AnyObject.Type {
return $0 as! T
} else {
return unsafeBitCast($0, to: T.self)
}
//
// 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 May 20, 2025 08:25
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
}
@randomsequence
randomsequence / CompareImages.swift
Last active October 2, 2024 21:09 — forked from ralfebert/CompareImages.swift
A couple of swift functions for comparing two CGImage using CIImage in OS X
//
// Thanks Kevin!
// https://gist.github.com/SheffieldKevin/566dc048dd6f36716bcd
//
import CoreGraphics
import CoreImage
extension CGImage {
@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 28, 2024 09:34
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