Skip to content

Instantly share code, notes, and snippets.

@steipete
steipete / PresentActionSheetWorkaround.mm
Last active January 27, 2020 04:32
UIKit has two places where it tries to present an action sheet on the rootViewController when it should present things on the topmost presentedViewController. This is our attempt of the least horrible workaround to fix this issue. (http://www.openradar.me/26295020).
#warning This still misses safeguards and has private API references in it. Use only when you really know what you're doing!
// pspdf_swizzleSelectorWithBlock not provided. Use your swizzling helper of choice
// (e.g. http://petersteinberger.com/blog/2014/a-story-about-swizzling-the-right-way-and-touch-forwarding/)
// Fixes rdar://26295020
static void PSPDFInstallWorkaroundForSheetPresentationIssue26295020(void) {
__block auto removeWorkaround = ^{};
const auto installWorkaround = ^{
const SEL presentSEL = @selector(presentViewController:animated:completion:);
@tebeka
tebeka / docker-compose.yml
Last active July 5, 2024 13:28
HAProxy in front of Elasticsearch
elastic:
image: elasticsearch
haproxy:
image: haproxy
volumes:
- ${PWD}:/usr/local/etc/haproxy
links:
- elastic
ports:
@kpettijohn
kpettijohn / docker_host_vsphere.sh
Created August 3, 2015 15:35
Example docker-machine vSphere create
#!/bin/bash
# Example docker-machine vSphere create
export VSPHERE_CPU_COUNT=4
export VSPHERE_MEMORY_SIZE=8192
export VSPHERE_DISK_SIZE=100000
export VSPHERE_VCENTER="vcenter.doamin.com"
export VSPHERE_USERNAME="DOAMIN\user"
export VSPHERE_PASSWORD=""
export VSPHERE_NETWORK="VM Traffic"
@douglashill
douglashill / NSKeyedUnarchiver secure decoding.m
Last active August 29, 2015 14:26
How to enable secure decoding with NSKeyedUnarchiver
// It isn’t immediately obvious how to enable secure decoding with NSKeyedUnarchiver.
// NSKeyedUnarchiver has a read-write requiresSecureCoding property, but we normally use:
id decodedObject = [NSKeyedUnarchiver unarchiveObjectWithData:archive];
// so never see an instance to be able to set this property.
// However, it is quite simple. The critical part is that we use the
// normal decodeObject… methods, passing the key of the root object.
NSData *archive;
@protrolium
protrolium / ffmpeg.md
Last active April 27, 2025 21:52
ffmpeg guide

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

You can get the list of installed codecs with:

#!/usr/bin/env bash
set -eufo pipefail
SUDO=""
if [ "$EUID" -ne 0 ]; then
SUDO="sudo"
if ! [ -x "$(command -v $SUDO)" ]; then
echo "Error: Running script as non-root and $SUDO is not installed. Exiting." >&2
exit 1
@omnicolor
omnicolor / headers.php
Created February 23, 2015 21:16
Unit testing headers with PHPUnit
<?php
/**
* Class that tries to send a header.
*/
class SendsHeaders {
/**
* Send a header to the user's browser.
*/
public function sendHeader() {
header('This is a header', true, 400);
@andymatuschak
andymatuschak / MultiDirectionAdjudicatingScrollView.swift
Created January 26, 2015 19:31
Source for the Khan Academy app's unusual scrolling interactions
//
// MultiDirectionAdjudicatingScrollView.swift
// Khan Academy
//
// Created by Andy Matuschak on 12/16/14.
// Copyright (c) 2014 Khan Academy. All rights reserved.
//
import UIKit
import UIKit.UIGestureRecognizerSubclass
@0xced
0xced / copy-reveal-dylib.sh
Last active March 15, 2016 15:11
Copy and codesign libReveal.dylib in Debug configuration (for use in a run script build phase)
#!/bin/bash -e
if [ "${CONFIGURATION}" != "Debug" ]; then
exit 0
fi
REVEAL_APP_PATH=$(mdfind -onlyin / "kMDItemCFBundleIdentifier == com.ittybittyapps.Reveal" | head -n 1)
if [ ! -d "${REVEAL_APP_PATH}" ]; then
echo "warning: Reveal.app not found."
exit 0
@albertbori
albertbori / Installation.md
Last active April 9, 2025 08:52
Automatically disable Wifi when an Ethernet connection (cable) is plugged in on a Mac

Overview

This is a bash script that will automatically turn your wifi off if you connect your computer to an ethernet connection and turn wifi back on when you unplug your ethernet cable/adapter. If you decide to turn wifi on for whatever reason, it will remember that choice. This was improvised from this mac hint to work with Yosemite, and without hard-coding the adapter names. It's supposed to support growl, but I didn't check that part. I did, however, add OSX notification center support. Feel free to fork and fix any issues you encounter.

Most the credit for these changes go to Dave Holland.

Requirements

  • Mac OSX 10+
  • Administrator privileges