Skip to content

Instantly share code, notes, and snippets.

View andr-ggn's full-sized avatar

Andrey Gagan andr-ggn

View GitHub Profile
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@"http://optimizerapi.ds.trustsourcing.com"]];
NSMutableURLRequest *request = [httpClient requestWithMethod:@"GET"
path:@"/Api/RestorePassword"
parameters:@{@"email":@"[email protected]"}];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[httpClient registerHTTPOperationClass:[AFHTTPRequestOperation class]];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
// Print the response body in text
NSLog(@"Response: %@", [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding]);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
[yourSwitchObject addTarget:self action:@selector(setState:) forControlEvents:UIControlEventValueChanged];
- (void)setState:(id)sender {
BOOL state = [sender isOn];
}
1). -------------------------------------------------------------
lazy var validator: Validator = { [unowned self] in
let validator = Validator()
validator.setSomething = "Foo"
validator.setSomethingMore = "Bar"
return validator
}()
2). -------------------------------------------------------------
var validator: Validator {
let validator = Validator()
/// Start
func drawCircles(count: Int) {
var cX = [CGFloat!](count: count, repeatedValue: nil)
var cY = [CGFloat!](count: count, repeatedValue: nil)
var i: Int = 0
var j: Int = 0
var n = count
var cR: CGFloat = 45
var dMinQ = pow(cR * 2, 2)
func iterateEnum<T: Hashable>(_: T.Type) -> AnyGenerator<T> {
var i = 0
return AnyGenerator {
let next = withUnsafePointer(&i) { UnsafePointer<T>($0).memory }
return next.hashValue == i++ ? next : nil
}
}
CATransaction.begin()
                    CATransaction.setDisableActions(true)
                    
                    let oldBottomOffset = self.collectionView.contentSize.height - self.collectionView.contentOffset.y
                    
                    self.collectionView.performBatchUpdates({
                        // indexPaths for earlier messages
                        let lastIdx = history.count - 1
                        //let lastIdx = self.messagesCountIndexes
                        var indexPaths: [AnyObject] = []
extension Collection where Iterator.Element: Comparable {
func lessThanFirst() -> [Iterator.Element] {
guard let first = self.first else { return [] }
return self.filter { $0 < first }
}
}
let items = [5, 6, 10, 4, 110, 3].lessThanFirst()
print(items)
NSLog(@"DEBUG ------");
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"`dispatch_get_main_queue`");
if (_delegate != nil) {
NSLog(@"`_delegate != nil`");
if ([_delegate respondsToSelector:@selector(onConversionDataSuccess:)]) {
NSLog(@"`respondsToSelector`");
[_delegate performSelector:@selector(onConversionDataSuccess:) withObject:conversionDict];
NSLog(@"conversionDict: %@", conversionDict);
NSLog(@"FINISH -------");
SEL mySel = @selector(onConversionDataSuccess:);
void (*myMsgSend)(id _delegate, SEL mySel, id param1);
myMsgSend = (void(*)(id, SEL, id))objc_msgSend;
myMsgSend(_delegate, mySel, conversionDict);
@echo off
setlocal
set GRADLEPATH=%~dp0
set GRADLE_CMD_LINE_ARGS=
:setupArgs
if ""%1""=="""" goto doneStart
set GRADLE_CMD_LINE_ARGS=%GRADLE_CMD_LINE_ARGS% %1
call "%GRADLEPATH%\gradlew.bat" :app:assembleRelease -Dfile.encoding=UTF-8
shift
goto setupArgs