Skip to content

Instantly share code, notes, and snippets.

@gruber
gruber / Liberal Regex Pattern for All URLs
Last active November 4, 2024 20:04
Liberal, Accurate Regex Pattern for Matching All URLs
The regex patterns in this gist are intended to match any URLs,
including "mailto:[email protected]", "x-whatever://foo", etc. For a
pattern that attempts only to match web URLs (http, https), see:
https://gist.github.com/gruber/8891611
# Single-line version of pattern:
(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))
@dimitribouniol
dimitribouniol / NSString+DBMoreStringAdditions.h
Created January 24, 2011 16:47
UIKit-based string additions for those who are going "Back to the Mac™"
#import <Cocoa/Cocoa.h>
@interface NSString (DBMoreStringAdditions)
- (CGSize)sizeWithFont:(NSFont *)aFont;
- (void)drawAtPoint:(CGPoint)point withFont:(NSFont *)aFont;
- (void)drawAtPoint:(CGPoint)point withFont:(NSFont *)aFont color:(NSColor *)aColor;
- (CGSize)sizeWithFont:(NSFont *)aFont actualFontSize:(CGFloat *)fontSize forWidth:(CGFloat)width;
- (CGSize)sizeWithFont:(NSFont *)aFont constrainedToSize:(CGSize)aSize;
if (typeof (AC) === "undefined") {
AC = {}
}
AC.ImageReplacer = Class.create({
_defaultOptions: {
listenToSwapView: true,
filenameRegex: /(.*)(\.[a-z]{3}($|#.*|\?.*))/i,
filenameInsert: "_☃x",
ignoreCheck: /(^http:\/\/movies\.apple\.com\/|\/105\/|\/global\/elements\/quicktime\/|_(([2-9]|[1-9][0-9]+)x|nohires)(\.[a-z]{3})($|#.*|\?.*))/i,
attribute: "data-hires",
@tadija
tadija / Xcode Semi-Automatic Versioning.md
Last active August 11, 2022 19:55
Xcode Semi-Automatic Versioning | Bump Build Number | Bump Version Number

Xcode Semi-Automatic Versioning

Instructions:

First Things First

In order for agvtool to work properly you must first set
Project Settings / Build Settings / Versioning / Versioning System to Apple Generic.

Bump Build Number

  1. Create new shared scheme 'Bump Build Number'
#import <Foundation/Foundation.h>
#import <assert.h>
//Compile with `clang -Os -framework Foundation -fno-objc-arc inlinestorage.m -o inline, run with `inline clever` or `inline naive`
/*
NaiveArray implements a simple immutable NSArray-like interface in probably the most obvious way: store a pointer to a C array of objects
*/
@interface NaiveArray : NSObject {
NSUInteger count;
@aydenp
aydenp / UIBackgroundStyle-Test.entitlements
Last active September 19, 2021 21:46 — forked from AppleBetas/gist:4ddf91c8ead4b2a87a71bcd52eab258b
Non-opaque application windows in iOS 7, with optional blur. Shows the user's wallpaper under the app, with Parallax if supported.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.springboard.appbackgroundstyle</key>
<true/>
</dict>
</plist>