Skip to content

Instantly share code, notes, and snippets.

View DominikBucher12's full-sized avatar
🚀
#YOLO

Dominik Bucher DominikBucher12

🚀
#YOLO
View GitHub Profile
public extension UIDevice {
/// This enum gives us simple way how to recognize which UIDevice size
///
/// For the resolutions, refer to
/// Apple official website:
/// https://developer.apple.com/library/archive/documentation/DeviceInformation/Reference/iOSDeviceCompatibility/Displays/Displays.html
/// Because the documentation is missing, I ran simulators and manually checked some resolutions on
/// `UIScreen.main.bounds` (for Xr, XS Max and 11-inch iPhones) Apple somehow doesn't update the documentation.
enum DeviceSize: CaseIterable {
// iPhones:
@DominikBucher12
DominikBucher12 / GetFastlaneVersion.swift
Last active October 15, 2018 14:05
Gets easily version of given gem with Swifty and decodable.
#!/usr/bin/swift
// Use this script to get name and version of gem passed as first argument
//
// Example usage: `swift GetFastlaneVersion.swift fastlane 1.0.2`
//
// Arguments: - `gem` - The name of gem you want to inspect.
// - `version` - The version you want to compare against the repo
//
// Because whole script runs in one thread, we need to use Semaphore to hold the thread until
// It finishes the asynch URLRequest. No mutex sorry 😔
@DominikBucher12
DominikBucher12 / Presentation_rotation.scpt
Created October 1, 2018 00:08
Presentation_rotation (not binary :( )
on run argv
(*set criteria to {"Portrait", "Landscape Left", "Landscape Right", "Portrait Upside Down"}*)
if (count of argv) = 1 then (*and (item 1 of argv) is in criteria then*)
set theExpectedWindowCount to item 1 of argv as integer
(* First we start with system event to work on Simulator and set it to foreground...*)
tell application "System Events" to tell process "Simulator"
set frontmost to true
set counter to 0
(* Set number of simulators containing Landscape to expected.*)
(* Then we iterate over windows in the process, simulator variable is here in fact the window *)
@DominikBucher12
DominikBucher12 / .bash_profile.sh
Created September 20, 2018 15:30
If you are curious about my .bash_profile.sh 🙈
# MARK: PATHS
source ~/.bashrc
# MARK: 🚀 Lastfane
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export GEM_PATH=/Users/dominikbucher/.rvm/rubies/ruby-2.4.1/bin/gem
# MARK: fkn' hkn'
@DominikBucher12
DominikBucher12 / create_latest_iOS_devices.sh
Created September 14, 2018 10:47
Simple script which installs latest version of simulators. Just list throught xcrun simctl list runtimes | devicetypes to see what fits for you. Modify as you wish.
#!/bin/bash
# Create landscape devices
# You should run this script everytime you install new Xcode with updated iOS version, because Xcode automatically deletes the older custom created simulators.
# This just works, we need to find better solution to get the runtime. I think this should do for a while.
runtime=$(xcrun simctl list runtimes | grep "iOS" | tail -1 | awk -F' - ' '{print $3F}')
echo $runtime
@DominikBucher12
DominikBucher12 / get_sloneek_token.sh
Last active September 2, 2018 20:14
Simple script for getting Json Web Token (JWT) for Sloneek API Auth.
#!/bin/bash
JSON_HEADER="Content-Type:application/json"
echo -n "Please enter your Working email:"
echo
read email
echo -n "Please enter your password:"
read -s password
@DominikBucher12
DominikBucher12 / Rotate_simulators.scpt
Last active September 30, 2018 23:12
This simple script rotates iOS simulators to given orientation. It can be used for example for UI Testing.
on run argv
set criteria to {"Portrait", "Landscape Left", "Landscape Right", "Portrait Upside Down"}
if (count of argv) = 2 and (item 1 of argv) is in criteria then
set theExpectedWindowCount to item 2 of argv as integer
(* First we start with system event to work on Simulator and set it to foreground...*)
tell application "Simulator" to activate
tell application "System Events" to tell process "Simulator"
set frontmost to true
set counter to 0
(* Then we iterate over windows in the process, simulator variable is here in fact the window *)
@DominikBucher12
DominikBucher12 / MakeOVPN.sh
Created March 21, 2018 19:29
Simple script for transforming Tunnelblick VPN configuration into OpenVPN configuration.
#!/bin/bash
# This is just very simple script (No error checking) for transformating the
# tunnelblick VPN configuration with multiple files
# into one file which contains the keys and certs in tags instead of separate file.
# This is good for example for using openVPN in Mobile devices, where you cannot put the Tunnelblick
# configuration file.
# Usage:
# - 1. Open terminal and change your directory to
@DominikBucher12
DominikBucher12 / GetLinesStrings.swift
Last active November 12, 2017 19:39
Swift Xcode extension snippet for getting array of strings from lines.
//
// GetLinesStrings.swift
//
// Created by Dominik Bucher on 22/10/2017.
// Copyright © 2017 Dominik Bucher. All rights reserved.
//
/// This method should be universal and implemented right from Apple.
/// gets specified text from line indexes
///