Skip to content

Instantly share code, notes, and snippets.

View AKupetskiy's full-sized avatar
🇺🇦

Andrii Kupetskyi AKupetskiy

🇺🇦
  • Amazon
  • Kraków, Poland
View GitHub Profile
@AKupetskiy
AKupetskiy / tableViewFix.m
Last active December 4, 2018 05:17
Fix: UITableView scrolls to top after method [tableView endUpdates]
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
CGPoint offset = tableView.contentOffset;
[tableView beginUpdates];
// do something
[tableView endUpdates]; //<- this method causes scrolling
[tableView.layer removeAllAnimations];
[tableView setContentOffset:offset animated:NO]; //<- Voilà! Now it works perfect :]
}
@AKupetskiy
AKupetskiy / dataGrabber.m
Last active May 20, 2016 14:02
grab date in format "Wednesday, the 13th July, 2015", find other formats here: http://waracle.net/iphone-nsdateformatter-date-formatting-table/
NSDate *date = [NSDate date];
NSDateFormatter *monthDayFormatter = [NSDateFormatter new];
[monthDayFormatter setDateFormat:@"F"];
int date_day = [[monthDayFormatter stringFromDate:date] intValue];
NSString *suffix_string = @"|st|nd|rd|th|th|th|th|th|th|th|th|th|th|th|th|th|th|th|th|th|st|nd|rd|th|th|th|th|th|th|th|st";
NSArray *suffixes = [suffix_string componentsSeparatedByString: @"|"];
NSString *suffix = [suffixes objectAtIndex:date_day];
@AKupetskiy
AKupetskiy / podforceupdate.sh
Created June 7, 2016 22:15 — forked from mbinna/podforceupdate.sh
Clear CocoaPods cache, re-download and re-install all pods
#!/usr/bin/env bash
rm -rf "${HOME}/Library/Caches/CocoaPods"
rm -rf "`pwd`/Pods/"
pod update
@AKupetskiy
AKupetskiy / gist:331f542dd9d7cc1848cc744cd0611a13
Created August 16, 2016 08:25
Fix textField text Font after toggling 'secureEntry' property
/// Kind of ugly hack to make the text refresh after the toggle. The size of the secure fonts are different than the normal ones and it shows trailing white space
[self resignFirstResponder];
NSString *text = self.text;
self.text = @" ";
self.text = text;
[self becomeFirstResponder];
@AKupetskiy
AKupetskiy / gist:e91b68a33a7f125cfc94b07c3e4e2753
Created September 1, 2016 12:47
share large files using AES256 encryption
//1. Generate public/private keys pair (Hit enter to skip questions):
openssl req -x509 -nodes -days 100000 -newkey rsa:2048 -keyout privatekey.pem -out publickey.pem
//2. Encrypt file using public key:
openssl smime -encrypt -aes256 -in LargeFile.zip -binary -outform DEM -out LargeFile_encrypted.zip publickey.pem
//3. Decrypt file using private key:
openssl smime -decrypt -in LargeFile_encrypted.zip -binary -inform DEM -inkey privatekey.pem -out LargeFile.zip
@AKupetskiy
AKupetskiy / implementationWithBlock.swift
Created April 9, 2017 16:27 — forked from neonichu/implementationWithBlock.swift
How to use imp_implementationWithBlock in Swift
import Foundation
import ObjectiveC.runtime
let myString = "foobar" as NSString
println(myString.description)
let myBlock : @objc_block (AnyObject!) -> String = { (sself : AnyObject!) -> (String) in
"✋"
}
### Keybase proof
I hereby claim:
* I am akupetskiy on github.
* I am andriykupetskyy (https://keybase.io/andriykupetskyy) on keybase.
* I have a public key ASD34btuZph4eOOaXO9iVP_pb_7adQAkTWAbvSuImH130wo
To claim this, I am signing this object: