Skip to content

Instantly share code, notes, and snippets.

View modestman's full-sized avatar

Anton Glezman modestman

View GitHub Profile
@Edudjr
Edudjr / Luhn.swift
Last active February 15, 2024 20:33 — forked from cwagdev/Luhn.swift
Luhn Algorithm in Swift 4.1
func luhnCheck(_ number: String) -> Bool {
var sum = 0
let digitStrings = number.reversed().map { String($0) }
for tuple in digitStrings.enumerated() {
if let digit = Int(tuple.element) {
let odd = tuple.offset % 2 == 1
switch (odd, digit) {
case (true, 9):
@DenTelezhkin
DenTelezhkin / MeasureAppStartupTime.swift
Last active November 27, 2023 07:28
Measure iOS app startup time, in seconds, from the time user tapped an icon on the home screen (using time, when app process was created). Swift 4.
// Returns number of seconds passed between time when process was created and function was called
func measureAppStartUpTime() -> Double {
var kinfo = kinfo_proc()
var size = MemoryLayout<kinfo_proc>.stride
var mib : [Int32] = [CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid()]
sysctl(&mib, u_int(mib.count), &kinfo, &size, nil, 0)
let start_time = kinfo.kp_proc.p_starttime
var time : timeval = timeval(tv_sec: 0, tv_usec: 0)
gettimeofday(&time, nil)
let currentTimeMilliseconds = Double(Int64(time.tv_sec) * 1000) + Double(time.tv_usec) / 1000.0
@hurricane-voronin
hurricane-voronin / README.md
Last active April 29, 2024 11:57
Naming Classes Without a 'Manager'
@stefanbuck
stefanbuck / upload-github-release-asset.sh
Last active November 26, 2023 12:40
Script to upload a release asset using the GitHub API v3.
#!/usr/bin/env bash
#
# Author: Stefan Buck
# License: MIT
# https://gist.github.com/stefanbuck/ce788fee19ab6eb0b4447a85fc99f447
#
#
# This script accepts the following parameters:
#
# * owner
@mitchwongho
mitchwongho / Docker
Last active November 29, 2023 06:36
Docker 'run' command to start an interactive BaSH session
# Assuming an Ubuntu Docker image
$ docker run -it <image> /bin/bash
@bubenkoff
bubenkoff / checkpoint.sh
Last active February 14, 2024 21:38
Endpoint Security VPN FULL start/stop script for Mac OS X
#!/bin/bash
#
# The reason of creating this script is that Endpoint Security VPN installs it's own application firewall kext cpfw.kext
# which prevents for example PPTP connections from this computer, which is not appropriate if you need subj connection just
# from time to time
#
# Usage: ./checkpoint.sh
#
# The script checks if Enpoint Security VPN is running. If it is, then it shuts it down, if it is not, it fires it up.
# Or, make an Automator action and paste the script.
@sekati
sekati / xcode-build-bump.sh
Created July 24, 2012 20:44
Xcode Auto-increment Build & Version Numbers
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)
@adamawolf
adamawolf / Apple_mobile_device_types.txt
Last active May 1, 2024 15:10
List of Apple's mobile device codes types a.k.a. machine ids (e.g. `iPhone1,1`, `Watch1,1`, etc.) and their matching product names
i386 : iPhone Simulator
x86_64 : iPhone Simulator
arm64 : iPhone Simulator
iPhone1,1 : iPhone
iPhone1,2 : iPhone 3G
iPhone2,1 : iPhone 3GS
iPhone3,1 : iPhone 4
iPhone3,2 : iPhone 4 GSM Rev A
iPhone3,3 : iPhone 4 CDMA
iPhone4,1 : iPhone 4S