Skip to content

Instantly share code, notes, and snippets.

View xr1337's full-sized avatar

Sufiyan Yasa xr1337

View GitHub Profile
@xr1337
xr1337 / gist:5318147
Created April 5, 2013 10:05
Taken from https://gist.github.com/iangmaia/3368412 and added an ignore to certain URL schemes such as mailto
- (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:5704176
Last active December 18, 2015 01:29
ViewController 1
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
@xr1337
xr1337 / gist:5704181
Last active December 18, 2015 01:29
RoundTouchButton 1
#import "RoundTouchButton.h"
@implementation RoundTouchButton
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
@xr1337
xr1337 / gist:5704189
Created June 4, 2013 07:23
Add Round Touch to View Controller
#import "ViewController.h"
#import "RoundTouchButton.h"
@xr1337
xr1337 / gist:5704267
Last active December 18, 2015 01:29
initialize roundtouchbutton
- (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:5704301
Last active December 18, 2015 01:29
Adding a touch Path
@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:5704489
Created June 4, 2013 08:32
PointInside
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event{
if (CGPathContainsPoint(touchPath, NULL, point, NO)) {
return YES;
}
return NO;
}
@xr1337
xr1337 / my_api_test.go
Created February 18, 2020 21:59
Syasa's 404 test
package main
import (
"io/ioutil"
"net/http"
"net/http/httptest"
"testing"
"github.com/pkg/errors"
)
@xr1337
xr1337 / ViewController.swift
Created March 19, 2020 09:17
A viewcontroller to get last event time on the system
//
// ViewController.swift
//
// Created by Sufiyan Yasa on 19/03/2020.
// Copyright © 2020 Sufiyan Yasa. All rights reserved.
//
import Cocoa
import CoreGraphics
@xr1337
xr1337 / Code.gs
Last active July 2, 2020 09:47
Google script to clean up root drive folder. All files are moved to their extension( mimetype) folder
/// returns extension from the file object
/// Queries the mimetype
const getExtension = function(file) {
var mime = file.getMimeType()
var docType = mime.split("/").pop()
return docType.split(".").pop()
};
/// send an email to myself when any files are moved