Skip to content

Instantly share code, notes, and snippets.

require 'optparse'
require 'xcodeproj'
options = {}
OptionParser.new do |opts|
opts.banner = " This script fills \"Compile sources\" and add headers to the project section. \n
Usage: fill_sources_headers.rb [options]"
opts.on("-s [sources_path]", "--sources [sources_path]", "Path to the sources files (required)") do |sources_path|
@dduan
dduan / NSAttributedString+SimpleHTMLTag.swift
Created December 7, 2014 05:59
Convert Simple Text With HTML Tags to NSAttributedString
extension NSAttributedString {
func replaceHTMLTag(tag: String, withAttributes attributes: [String: AnyObject]) -> NSAttributedString {
let openTag = "<\(tag)>"
let closeTag = "</\(tag)>"
let resultingText: NSMutableAttributedString = self.mutableCopy() as NSMutableAttributedString
while true {
let plainString = resultingText.string as NSString
let openTagRange = plainString.rangeOfString(openTag)
if openTagRange.length == 0 {
@jernejstrasner
jernejstrasner / HMACDigest.swift
Last active May 4, 2020 14:54
HMAC digest in Swift
// Make sure you add #import <CommonCrypto/CommonCrypto.h> to the Xcode bridging header!
enum CryptoAlgorithm {
case MD5, SHA1, SHA224, SHA256, SHA384, SHA512
var HMACAlgorithm: CCHmacAlgorithm {
var result: Int = 0
switch self {
case .MD5: result = kCCHmacAlgMD5
case .SHA1: result = kCCHmacAlgSHA1