Skip to content

Instantly share code, notes, and snippets.

import Foundation
import PlaygroundSupport
/// A thread-safe array.
public class SynchronizedArray<Element> {
private let queue = DispatchQueue(label: "io.zamzam.ZamzamKit.SynchronizedArray", attributes: .concurrent)
private var array = [Element]()
public init() { }
extension String {
static func stringFromCStringDetectingEncoding(CString: UnsafePointer<CChar>, suggestedEncodings: Set<NSStringEncoding> = [], disallowedEncodings: Set<NSStringEncoding> = []) -> (string: String, encoding: NSStringEncoding, lossy: Bool)? {
let data = NSData(bytesNoCopy: UnsafeMutablePointer<Void>(CString), length: Int(strlen(CString)), freeWhenDone: false)
var outString: NSString? = nil
var lossyConversion: ObjCBool = false
var encodingOptions = [String: AnyObject]()
if !suggestedEncodings.isEmpty {
@dstapp
dstapp / setup_osx.sh
Last active January 11, 2022 23:15
OS X setup script (currently 10.11)
#!/bin/bash
# Homebrew requires Xcode CLI tools to be installed. OS X provides stubs for CLI tools
# that trigger the CLI tools installer when called. So we call `git` to start the installation.
git
echo "Press any key when Xcode CLI tools installation is complete..."
read
# Install Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@cfont
cfont / pre-commit.py
Created March 10, 2016 23:19 — forked from dandye/pre-commit.py
pre-commit hook to re-write the TravisCI Badge with the current branch. Save as `.git/hooks/pre-commit` (without the .py extension)
#!/usr/bin/python
"""
Referencing current branch in github readme.md[1]
This pre-commit hook[2] updates the README.md file's
Travis badge with the current branch
[1] http://stackoverflow.com/questions/18673694/referencing-current-branch-in-github-readme-md
[2] http://www.git-scm.com/book/en/v2/Customizing-Git-Git-Hooks
[3] https://docs.travis-ci.com/user/status-images/

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

@nicklockwood
nicklockwood / Hacking UIView Animation Blocks.md
Last active August 24, 2024 17:08
This article was originally written for objc.io issue 12, but didn't make the cut. It was intended to be read in the context of the other articles, so if you aren't familiar with concepts such as CALayer property animations and the role of actionForKey:, read the articles in that issue first.

Hacking UIView animation blocks for fun and profit

In this article, I'm going to explore a way that we can create views that implement custom Core Animation property animations in a natural way.

As we know, layers in iOS come in two flavours: Backing layers and hosted layers. The only difference between them is that the view acts as the layer delegate for its backing layer, but not for any hosted sublayers.

In order to implement the UIView transactional animation blocks, UIView disables all animations by default and then re-enables them individually as required. It does this using the actionForLayer:forKey: method.

Somewhat strangely, UIView doesn't enable animations for every property that CALayer does by default. A notable example is the layer.contents property, which is animatable by default for a hosted layer, but cannot be animated using a UIView animation block.

@43z3com
43z3com / build-ios-ffmpeg.sh
Created June 19, 2014 10:09
ffmpegをiOS用にビルドします。ダウンロード、toolchainsの作成、複数のアーキテクチャのビルドまでを自動で行います。デフォルトでは2.2.3をi386 x86_64 armv7 armv7sのアーキテクチャを作成します。arm64にするとエラーする Build for iOS and ffmpeg. Build a full auto of architecture and multiple creation of toolchains and downloads Create the following architecture, version 2.2.3 by default i386 x86_64 armv7 armv7s
#!/bin/bash
: << '#__REM__'
ffmpegをiOS用にビルドします。ダウンロード、toolchainsの作成、複数のアーキテクチャのビルドまでを自動で行います。デフォルトでは2.2.3をi386 x86_64 armv7 armv7sのアーキテクチャを作成します。arm64にするとエラーする
Build for iOS and ffmpeg. Build a full auto of architecture and multiple creation of toolchains and downloads Create the following architecture, version 2.2.3 by default
i386 x86_64 armv7 armv7s
#__REM__
@patrickhammond
patrickhammond / android_instructions.md
Last active July 22, 2025 02:25
Easily setup an Android development environment on a Mac

Here is a high level overview for what you need to do to get most of an Android environment setup and maintained.

Prerequisites (for Homebrew at a minimum, lots of other tools need these too):

  • XCode is installed (via the App Store)
  • XCode command line tools are installed (xcode-select --install will prompt up a dialog)
  • Java

Install Homebrew:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

@denji
denji / README.md
Last active February 11, 2025 10:01 — forked from istepanov/gist:3950977
Remove/Backup – settings & cli for macOS (OS X) – DataGrip, AppCode, CLion, Gogland, IntelliJ, PhpStorm, PyCharm, Rider, RubyMine, WebStorm