Skip to content

Instantly share code, notes, and snippets.

View rogerluan's full-sized avatar
🚀

Roger Oba rogerluan

🚀
View GitHub Profile
@rogerluan
rogerluan / Regex+Utilities.swift
Last active July 27, 2020 02:51
A few regex utilities in Swift.
extension NSRegularExpression {
convenience init(_ pattern: String) {
do {
try self.init(pattern: pattern)
} catch {
preconditionFailure("Illegal regular expression with pattern: \(pattern)")
}
}
func matches(_ string: String, options: NSRegularExpression.MatchingOptions = []) -> Bool {
@rogerluan
rogerluan / PHPickerViewControllerSample.swift
Created June 29, 2020 10:11
PHPickerViewController configuration
var configuration = PHPickerConfiguration()
configuration.filter = .images
configuration.selectionLimit = 0
let picker = PHPickerViewController(configuration: configuration)
picker.delegate = self
present(picker, animated: true)
@rogerluan
rogerluan / brazil-geographic-coverage.geojson
Last active May 14, 2019 18:12
Cobertura geográfica do Brasil em formato GeoJSON, nos moldes da Apple, para submissão no iTunes Connect.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rogerluan
rogerluan / android-studio-config-27-jul-2018.xml
Created July 27, 2018 04:35
Android Studio Code Style Configuration
<code_scheme name="Default" version="173">
<option name="RIGHT_MARGIN" value="100" />
<AndroidXmlCodeStyleSettings>
<option name="USE_CUSTOM_SETTINGS" value="true" />
</AndroidXmlCodeStyleSettings>
<JavaCodeStyleSettings>
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
<value />
@rogerluan
rogerluan / CAAnimation Shake Animation
Created July 6, 2016 15:03
A shake animation that resembles an error animation feedback. It happens once - it's not a constant wiggling like SpringBoard app edit wiggle animation.
/**
* @Credits: paiego
* @Description: edited paiego's code to adapt to my use (error animation feedback)
* @See: http://stackoverflow.com/a/9753948/4075379
*/
- (CAAnimation *)shakeAnimation {
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
CGFloat wobbleAngle = 0.06f;
@rogerluan
rogerluan / itemPressed
Created November 18, 2015 16:45
Code snippet for blog series.
#import "TableDelegate.h"
//adicionar antes do último @end
#pragma mark - IBActions -
- (IBAction)itemPressed:(TableDelegate*)sender {
TableData *data = sender.selectedData;
UIAlertController *alert = [UIAlertController alertControllerWithTitle:data.title message:
@rogerluan
rogerluan / TableCoordinator
Created November 18, 2015 16:31
Code snippet for blog series.
//TableCoordinator.h
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface TableCoordinator : NSObject
@property (nonatomic, strong) IBOutlet UITableView *tableView;
- (void)reloadData:(NSArray *)data;
@rogerluan
rogerluan / TableDelegate
Created November 18, 2015 16:23
Code snippet for blog series.
//TableDelegate.h
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface TableDelegate : UIControl <UITableViewDelegate>
@property (nonatomic, strong) NSArray *data;
@property (readonly) id selectedData;
@rogerluan
rogerluan / TableDataSource
Created November 18, 2015 16:21
Code snippet for blog series.
//TableDataSource.h
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface TableDataSource : NSObject<UITableViewDataSource>
@property (nonatomic, strong) NSArray *data;
@end
@rogerluan
rogerluan / reloadData
Created November 18, 2015 13:29
Code snippet for blog series.
- (void)reloadData {
[self.refreshControl beginRefreshing];
[self.dataManager getData:^(NSArray *json) {
//converte os objetos do servidor no nosso modelo de objetos
NSMutableArray *items = [NSMutableArray array];
for (NSDictionary *jsonItem in json) {
TableData *item = [[TableData alloc] initWithJSON:jsonItem];
item.position = [NSNumber numberWithInteger:[json indexOfObject:jsonItem]+1];