Skip to content

Instantly share code, notes, and snippets.

View sbhmajd's full-sized avatar

Majd Sabah sbhmajd

View GitHub Profile
@nyg
nyg / AddJPEGComment.swift
Last active February 21, 2021 05:17
Add a JPEG comment marker to file in pure Swift.
//
// Inspired by wrjpgcom of libjpeg
// https://github.com/libjpeg-turbo/libjpeg-turbo/blob/master/wrjpgcom.c
//
// https://stackoverflow.com/a/46045524/5536516
//
// Note: To add an EXIF UserComment go here:
// https://gist.github.com/nyg/c90f36abbd30f72c8b6681ef23db886b
import Foundation
@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
@PaulWagener
PaulWagener / Keychain.swift
Created November 1, 2017 07:09
Easy Keychain use with Swift 4
//
// Keychain.swift
// SecKeychain
//
// Created by Paul Wagener on 01-11-17.
// Copyright © 2017 Paul Wagener. All rights reserved.
//
import Foundation
@GenoZhou
GenoZhou / UITableView.swift
Created November 5, 2017 15:34
Swift 4 UITableView extensions.
public protocol ReusableView: class { }
extension ReusableView where Self: UIView {
public static var reuseIdentifier: String {
return String(describing: self)
}
}
extension UITableViewCell: ReusableView { }
extension UITableViewHeaderFooterView: ReusableView { }
@robertmryan
robertmryan / Ranges.swift
Last active February 29, 2024 16:16
Swift 4 string extension to find all ranges of some substring
extension StringProtocol where Index == String.Index {
func ranges<T: StringProtocol>(of substring: T, options: String.CompareOptions = [], locale: Locale? = nil) -> [Range<Index>] {
var ranges: [Range<Index>] = []
while let result = range(of: substring, options: options, range: (ranges.last?.upperBound ?? startIndex)..<endIndex, locale: locale) {
ranges.append(result)
}
return ranges
}
}

If .DS_Store was never added to your git repository, simply add it to your .gitignore file.

If you don't have one, create a file called

.gitignore

In your the root directory of your app and simply write

@rhodrid
rhodrid / com.jenkins.ci.plist
Created August 1, 2018 10:57
MacOS: Run Jenkins Slave as a Service
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.jenkins.ci</string>
<key>UserName</key>
<string>jenkins</string>
<key>SessionCreate</key>
<true/>
@standinga
standinga / main.swift
Created November 18, 2018 00:16
Read MJPEG int CGImage using Swift4, URLSession, OSX
//
// main.swift
// MJPEGreader
//
// Created by michal on 17/11/2017.
// Copyright © 2018 michal. All rights reserved.
//
import Foundation
@matsuda
matsuda / Fastfile
Created May 8, 2019 10:37
指定されたブランチを取得するlane
###############################
# get latest release git branch
###############################
desc "get latest release git branch"
private_lane :git_latest_release_branch do
pattern = "release\/(.+)"
branches = git_find_branches(pattern: pattern)
reg = Regexp.new(pattern)
branches = branches.sort { |a, b|
#!/bin/sh
# https://gist.github.com/MarioIannotta/e27ac3ec067dc5b6f00c392d7527b10a
build_path="Builds/$(date '+%d-%m-%Y-%H-%M')"
target="YourFramework"
configuration="Your configuration eg: Release"
# clean up the build folder if already exists
rm -rf build_path