Skip to content

Instantly share code, notes, and snippets.

@antongaenko
antongaenko / CopyMenuCollectionViewCell
Created October 27, 2014 15:16
Allow copy action for chat messages
- (BOOL)collectionView:(UICollectionView *)collectionView shouldShowMenuForItemAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
- (BOOL)collectionView:(UICollectionView *)collectionView canPerformAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender
{
return action == @selector(copy:);
}
@antongaenko
antongaenko / apns-certificate-creator.sh
Last active April 17, 2017 18:58
Create server APNS certificate
#!/bin/sh
#
# Install by copy/paste
# curl -O https://gist.githubusercontent.com/Just-/f3c92cf8d76abe1f8be0/raw/4181b5fce861037ec10c44c80250bb8a8c38f841/apns-certificate-creator.sh && chmod +x apns-certificate-creator.sh && cp apns-certificate-creator.sh /usr/local/bin/apns-certificate-creator
# Create APNS server certificate
# $1 - APNS SSL cert from developer.apple.com (.cer)
# $2 - developer private key exported from keychain (.p12)
# $3 - output certificate with password (.pem)
@antongaenko
antongaenko / resize_ios_icons.sh
Last active December 24, 2016 23:43
Resize big icon to make iOS 7+ icon set
#!/bin/sh
# Generate icons for >= iOS 7
#
# Install
# curl -o /usr/local/bin/resize_ios_icons -O https://gist.githubusercontent.com/Just-/8fa383eb690ac6dd0601/raw/36d49d9c2deda6844776abbaf0da127759176d2c/resize_ios_icons.sh && chmod +x /usr/local/bin/resize_ios_icons
#
# Params: 1 - icon to resize (fe 512px or 1024px)
# 2 - dir to generate
#
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- array of downloads. -->
<key>items</key>
<array>
<dict>
<!-- an array of assets to download -->

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

// make .strings from all NSLocalizedString occuerences
find ./ -name "*.m" -print0 | xargs -0 genstrings
// Count words in a file for localization cost estimate
cat Localizable.strings | grep ';$' | awk -F= '{ print $2 }' | wc -w
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# Step 1. Build Device and Simulator versions
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
# Step 2. Copy the framework structure to the universal folder
@antongaenko
antongaenko / generate_umbrella.rb
Created June 21, 2017 15:53 — forked from tyronet-sportsbet/generate_umbrella.rb
Generates a naïve umbrella header by assuming every header in the working folder or any of its subfolders is public and should be included
#!/usr/bin/env ruby
# Your umbrella header needs a comment in it like the below so this script
# knows which parts to replace
#
# /* IMPORTS BEGIN */
#
# /* IMPORTS END */
MODULE = ARGV[0] || File.basename(Dir.getwd)