Skip to content

Instantly share code, notes, and snippets.

@amirrajan
amirrajan / winding_number.rb
Created September 24, 2020 18:33
Winding number collision detection in Ruby.
# coding: utf-8
module Geometry
class Points
def initialize array
@array = array
end
def point_inside? point
return false unless point.inside_rect? rect
winding_number(point) == 0
@mackuba
mackuba / wwdc15.md
Last active August 6, 2022 17:28
New stuff from WWDC 2015

Here's my own list of the interesting stuff announced during this year's WWDC, collected from the keynotes, various Apple docs, blog posts and tweets.

If you're planning to watch the videos, I really recommend this Mac app that helps you download and watch them: https://github.com/insidegui/WWDC.

OS X El Capitan

http://www.apple.com/osx/elcapitan-preview/

  • split view - two apps side by side on full screen
@jlnquere
jlnquere / UICollectionViewScroll.swift
Last active June 10, 2022 14:25
XCUITests: scroll UICollectionView to find one of it's offscreen UICollectionViewCell by id
// Thanks to @MonsieurDart for the idea :)
func scroll(collectionView:XCUIElement, toFindCellWithId identifier:String) -> XCUIElement? {
guard collectionView.elementType == .collectionView else {
fatalError("XCUIElement is not a collectionView.")
}
var reachedTheEnd = false
var allVisibleElements = [String]()
while !reachedTheEnd {
@mtauraso
mtauraso / add_launchd_to_tcc.sh
Last active February 10, 2021 04:45
TCC Database Script
#!/bin/bash
# This will add lauchd to the list of allowed processes for accessibility access
sudo sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db "INSERT or REPLACE INTO access VALUES('kTCCServiceAccessibility','/sbin/launchd',1,1,1,NULL)"
# This outputs the rows in the TCC database
sudo sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db 'select * from access'
echo "Restart is required for these changes to take effect"
@brentsimmons
brentsimmons / gist:5810992
Last active January 3, 2021 02:22
Detect a tap on a URL inside a UITextView. Note: the rs_links method isn't included -- you'll need something that takes text and returns an array of detected links. This gist just demonstrates walking through the UITextView characters.
@implementation UITextView (RSExtras)
static BOOL stringCharacterIsAllowedAsPartOfLink(NSString *s) {
/*[s length] is assumed to be 0 or 1. s may be nil.
Totally not a strict check.*/
if (s == nil || [s length] < 1)
return NO;
@phatblat
phatblat / package-ida.sh
Created May 11, 2015 16:53
A quick script to package up an .ipa correctly since `xcodebuild -exportArchive` misses the required SwiftSupport and WatchKitSupport folders
#!/bin/bash -e
#
# package-ipa.sh
#
# Bundles an iOS app correctly, using the same directory structure that Xcode does when using the export functionality.
#
xcarchive="$1"
output_ipa="$2"