Skip to content

Instantly share code, notes, and snippets.

@xr1337
xr1337 / gist:5318147
Created Apr 5, 2013
Taken from https://gist.github.com/iangmaia/3368412 and added an ignore to certain URL schemes such as mailto
View gist:5318147
- (NSArray *) extractLinksFromString:(NSString*)txt ignoreSchemes:(NSArray*)ignoreSchemes{
NSError *error = NULL;
NSDataDetector *detector = [NSDataDetector dataDetectorWithTypes:NSTextCheckingTypeLink error:&error];
if (error) return nil;
NSArray *linkMatches = [detector matchesInString:txt options:0 range:NSMakeRange(0, txt.length)];
NSMutableArray *result = [NSMutableArray arrayWithCapacity:[linkMatches count]];
@xr1337
xr1337 / gist:5704267
Last active Dec 18, 2015
initialize roundtouchbutton
View gist:5704267
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
RoundTouchButton *rtb = [[RoundTouchButton alloc]initWithFrame:CGRectMake(0, 0, 200, 200)];
rtb.backgroundColor = [UIColor orangeColor];
[rtb addTarget:self action:@selector(rtbTapped) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:rtb];
}
@xr1337
xr1337 / gist:5704176
Last active Dec 18, 2015
ViewController 1
View gist:5704176
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
@xr1337
xr1337 / gist:5704301
Last active Dec 18, 2015
Adding a touch Path
View gist:5704301
@implementation RoundTouchButton{
CGPathRef touchPath;
}
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
touchPath = CGPathCreateWithEllipseInRect(CGRectMake(0, 0, self.frame.size.width, self.frame.size.height), NULL);
@xr1337
xr1337 / gist:5704189
Created Jun 4, 2013
Add Round Touch to View Controller
View gist:5704189
#import "ViewController.h"
#import "RoundTouchButton.h"
@xr1337
xr1337 / gist:5704181
Last active Dec 18, 2015
RoundTouchButton 1
View gist:5704181
#import "RoundTouchButton.h"
@implementation RoundTouchButton
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
View gist:5704489
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event{
if (CGPathContainsPoint(touchPath, NULL, point, NO)) {
return YES;
}
return NO;
}
@xr1337
xr1337 / my_api_test.go
Created Feb 18, 2020
Syasa's 404 test
View my_api_test.go
package main
import (
"io/ioutil"
"net/http"
"net/http/httptest"
"testing"
"github.com/pkg/errors"
)
@xr1337
xr1337 / ViewController.swift
Created Mar 19, 2020
A viewcontroller to get last event time on the system
View ViewController.swift
//
// ViewController.swift
//
// Created by Sufiyan Yasa on 19/03/2020.
// Copyright © 2020 Sufiyan Yasa. All rights reserved.
//
import Cocoa
import CoreGraphics
@xr1337
xr1337 / application.rb
Created Jun 30, 2020
Snapshot of Fastlane - spaceship/lib/spaceship/tunes/application.rb
View application.rb
# Taken from https://github.com/fastlane/fastlane/blob/master/spaceship/lib/spaceship/tunes/application.rb
# @return (Spaceship::Tunes::Application) Returns the application matching the parameter
# as either the App ID or the bundle identifier
def find(identifier, mac: false)
all.find do |app|
((app.apple_id && app.apple_id.casecmp(identifier.to_s) == 0) || (app.bundle_id && app.bundle_id.casecmp(identifier.to_s) == 0)) &&
app.version_sets.any? { |v| (mac ? ["osx"] : ["ios", "appletvos"]).include?(v.platform) }
end
end