Skip to content

Instantly share code, notes, and snippets.

View Galeas's full-sized avatar
🇺🇦
#standwithukraine

Evgeniy Branitsky Galeas

🇺🇦
#standwithukraine
View GitHub Profile
@Galeas
Galeas / joke
Created December 13, 2021 09:37
English: A dog.
Swedish: What?
English: The dog.
English: Two dogs.
Swedish: Okay. We have: En hund, hunden, Två hundar, hundarna.
@Galeas
Galeas / DispatchOnce.swift
Created October 15, 2020 17:18
Swift 3+ GCD's dispatch_once
extension DispatchQueue {
private static var _onceTracker = [String]()
func once(file: String = #file, function: String = #function, line: Int = #line, _ block:() -> Void) {
let token = file + ":" + function + ":" + String(line)
once(token: token, block)
}
/// Executes a block of code, associated with a unique token, only once. The code is thread safe and will
/// only execute the code once even in the presence of multithreaded calls.
@Galeas
Galeas / sockd.conf
Created April 17, 2018 11:23
Dante config
#logoutput: /var/log/socks.log
logoutput: stderr
# socks clients interface and port
internal: eth0 port = 1080
# external interface and port
external: eth0
#internal: x.x.x.x port = 1080
#external: x.x.x.x
@Galeas
Galeas / sockd
Last active April 17, 2018 11:21
Dante run script
#! /bin/sh
### BEGIN INIT INFO
# Provides: sockd
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start the dante SOCKS server.
# Description: SOCKS (v4 and v5) proxy server daemon (sockd).
# This server allows clients to connect to it and
CGFloat hue = ( arc4random_uniform(256) / 256.0 ); // 0.0 to 1.0
CGFloat saturation = ( arc4random_uniform(128) / 256.0 ) + 0.5; // 0.5 to 1.0, away from white
CGFloat brightness = ( arc4random_uniform(128) / 256.0 ) + 0.5; // 0.5 to 1.0, away from black
UIColor *color = [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:1];
@Galeas
Galeas / KeyboardAdjuster.h
Last active March 20, 2018 11:32
iOS AutoLayout Keyboard Adjuster
@import UIKit;
typedef void (^KeyboardAdjustingBlock)();
@interface KeyboardAdjuster : NSObject
@property (nonatomic, assign) BOOL activated;
@property (nonatomic, nullable, weak) IBOutlet UIView *targetView;
@property (nonatomic, nullable, weak) IBOutlet NSLayoutConstraint *targetConstraint;
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## Build generated
build/
DerivedData/
## Various settings
*.pbxuser
@Galeas
Galeas / gist:829dc9cd022cd34f478e
Created July 15, 2015 13:14
Xcode auto-increment build number
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CWBuildNumber" ${PROJECT_DIR}/TestIncrement/TestIncrement-Info.plist)
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CWBuildNumber $buildNumber" ${PROJECT_DIR}/TestIncrement/TestIncrement-Info.plist
@Galeas
Galeas / gist:f212b1e8635f88e834c0
Last active August 29, 2015 14:25
Version number & build on iOS app icon
# необходимы установленные пакеты imagemagick и ghostscript
# если у нас релизная сборка, то нам нужна обычная иконка
if [ $CONFIGURATION = "Release" ]; then
return
fi
# номер версии
version=`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${INFOPLIST_FILE}"`
# номер билда
build=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${INFOPLIST_FILE}"`
@Galeas
Galeas / gist:8348748
Last active January 2, 2016 19:09
UIColor from HEX
+ (UIColor *)colorWithHex:(NSString *)hexColor
{
// Remove the hash if it exists
hexColor = [hexColor stringByReplacingOccurrencesOfString:@"#" withString:@""];
int length = (int)[hexColor length];
bool triple = (length == 3);
NSMutableArray *rgb = [[NSMutableArray alloc] init];
// Make sure the string is three or six characters long
if (triple || length == 6) {
CFIndex i = 0;