Skip to content

Instantly share code, notes, and snippets.

@xr1337
xr1337 / Example script to open all logs
Last active May 24, 2021
A script to stream all the logs that simulator is currently booted
View Example script to open all logs
#/bin/bash
A=`xcrun simctl list | grep Booted | perl -ne 'print "$1\n" if / \(([0-9A-Z\-]+)\) /' | sort | uniq `
for UUID in $A
do
xcrun simctl spawn $UUID log stream --level debug\
--timeout 1h\
--style compact \
--predicate 'subsystem == "my.domain.name"' &
done
@xr1337
xr1337 / question.swift
Created Aug 10, 2020
unique substrings
View question.swift
import Cocoa
func fewestCoins(coins: String) -> Int {
let coinsArray = Array(coins)
let checkSet :Set = Set(coinsArray)
let countedSet :NSCountedSet = NSCountedSet()
// validation when the lenght of the string == amount uniq characters
if(checkSet.count == coins.count || checkSet.count == 0) {
return coins.count
@xr1337
xr1337 / main.go
Created Aug 10, 2020
medical_records
View main.go
package main
import (
"encoding/json"
"fmt"
"net/http"
"sort"
"time"
)
@xr1337
xr1337 / Code.gs
Last active Jul 2, 2020
Google script to clean up root drive folder. All files are moved to their extension( mimetype) folder
View Code.gs
/// 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
@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
@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 / 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"
)
View gist:5704489
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event{
if (CGPathContainsPoint(touchPath, NULL, point, NO)) {
return YES;
}
return NO;
}
@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: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];
}