Skip to content

Instantly share code, notes, and snippets.

View krin-san's full-sized avatar

Alexander Chapliuk krin-san

  • Joyn GmbH
  • Munich, Germany
View GitHub Profile
krin-san /
Created November 16, 2021 09:32
List gems without reverse dependencies
# Provides list of gems that have nothing depending on them
for target in $(gem list -l --no-verbose | cut -d ' ' -f 1); do
if [ "$(gem dependency -lr $target | wc -l)" -eq 2 ]; then
echo "$target"
krin-san / CFNetworkErrors.h
Last active September 28, 2023 10:26
Apple NSURLError and CFNetworkError codes
typedef CF_ENUM(int, CFNetworkErrors) {
kCFHostErrorHostNotFound = 1,
kCFHostErrorUnknown = 2, // Query the kCFGetAddrInfoFailureKey to get the value returned from getaddrinfo; lookup in netdb.h
// SOCKS errors; in all cases you may query kCFSOCKSStatusCodeKey to recover the status code returned by the server
kCFSOCKSErrorUnknownClientVersion = 100,
kCFSOCKSErrorUnsupportedServerVersion = 101, // Query the kCFSOCKSVersionKey to find the version requested by the server
// SOCKS4-specific errors
kCFSOCKS4ErrorRequestFailed = 110, // request rejected or failed by the server
kCFSOCKS4ErrorIdentdFailed = 111, // request rejected because SOCKS server cannot connect to identd on the client

Build libimobiledevice and ifuse from HEAD

Install development packages via Brew. If you're using OS X 10.12+, install osxfuse via cask as Brew suggest in error output.

brew tap homebrew/fuse
brew install --HEAD usbmuxd
brew install --HEAD libimobiledevice
brew install --HEAD ifuse
krin-san / Podfile
Last active August 30, 2016 08:38
Collection of Pods
platform :ios, '9.0'
# Guide and example for a neat way to modify pods using patchfiles
post_install do | installer |
`patch -p0 < Diffs/TARGET_FILE.m.diff`
krin-san / CropVideo.m
Created June 22, 2016 06:17 — forked from zrxq/CropVideo.m
Crop video to square with a specified side respecting the original video orientation
@import MobileCoreServices;
@import AVFoundation;
@import AssetsLibrary;
// ...
- (void)cropVideoAtURL:(NSURL *)videoURL toSquareWithSide:(CGFloat)sideLength completion:(void(^)(NSURL *resultURL, NSError *error))completionHander {
/* asset */
krin-san / ToggleConstraint.m
Last active October 1, 2020 07:23
NSLayoutConstraint with a two possible states and a flag to toggle between them
#import <UIKit/UIKit.h>
/// This constraint could be toggled between two values (min/max) by `enlarged` flag
@interface ToggleConstraint : NSLayoutConstraint
Max size of the height/width/offset/etc.
Think about it as some UI element can change it's size between min and max values.
@property (nonatomic, assign) IBInspectable BOOL enlarged;
krin-san / ScalingConstraint.m
Last active August 23, 2016 08:25
NSLayoutConstraint with UIScreen scaling. Comes useful for a the thin separator views to be a 1px width on any screen
#import <UIKit/UIKit.h>
/// Allows to use a 1px wide delimiter views
@interface ScalingConstraint : NSLayoutConstraint
@implementation ScalingConstraint
- (CGFloat)constant {
return [super constant] / [UIScreen mainScreen].scale;
krin-san / CoreTelephonyCheck.swift
Created November 9, 2015 12:39
Check if iOS device is capable to call / send SMS message
// Swift version of the code from
import CoreTelephony
override func awakeFromNib() {
let isCapableToCall: Bool
if UIApplication.sharedApplication().canOpenURL(NSURL(string: "tel://")!) {
// Check if iOS Device supports phone calls
krin-san / happy_birthday.mikrotik
Created October 30, 2015 22:27
Happy Birthday song played using a speaker
:beep frequency=264 length=250ms;
:delay 500ms;
:beep frequency=264 length=250ms;
:delay 250ms;
:beep frequency=297 length=1000ms;
:delay 250ms;
:beep frequency=264 length=1000ms;
:delay 250ms;
:beep frequency=352 length=1000ms;
:delay 250ms;
krin-san / iOSVersionCheck.h
Last active September 8, 2016 19:30
NSProcessInfo-based iOS version check macro (iOS 8+)
#define INC_SYSTEM_VERSION(v) ((NSOperatingSystemVersion){v.majorVersion, v.minorVersion + 1, 0})
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) [[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:v]
// Manual logical check
NSOperatingSystemVersion v = (NSOperatingSystemVersion){8, 4, 0};