Skip to content

Instantly share code, notes, and snippets.

@buranmert
buranmert / upload_symbols_to_datadog.rb
Created November 10, 2021 13:23
Upload symbols to Datadog fastlane action
module Fastlane
module Actions
class UploadSymbolsToDatadogAction < Action
def self.run(params)
UI.message("Datadog API Key: #{params[:api_key]}")
UI.message("dSYM Path: #{params[:dsym_path]}")
ENV['DATADOG_API_KEY'] = params[:api_key]
cmd = 'npx @datadog/datadog-ci dsyms upload '
cmd += params[:dsym_path]
@buranmert
buranmert / NetworkAutoinstrumentation.swift
Created December 14, 2020 17:47
Network Autoinstrumentation
import Foundation
import ObjectiveC
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
func swizzleInit() {
let selector = #selector(URLSession.init(configuration:delegate:delegateQueue:))
let method = class_getClassMethod(URLSession.self, selector)!
typealias ImpBlock = @convention(block) (AnyClass, URLSessionConfiguration, URLSessionDelegate?, OperationQueue?) -> URLSession
@buranmert
buranmert / HookedSession.swift
Last active October 26, 2022 06:36
Adding hooks to URLSession
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2019-2020 Datadog, Inc.
*/
import Foundation
public extension URLSession {
internal typealias RequestInterceptor = HookedSession.RequestInterceptor
@buranmert
buranmert / README.md
Last active March 22, 2017 13:39
Augment-iOS Technical Assignment

Augment iOS Technical Assignment

There is no restrictions on 3rd party libraries and package managers. But please use them only if they make things easier. We expect you to write in Objective-C or the latest version of Swift.

TheAppWithZeroUsers (feel free to find a fancier name to your demo app!)

TheAppWithZeroUsers is a great app where you list the items that you get via a network endpoint and you can favorite/unfavorite them by tapping on the items. Thanks to this great favorite feature, you can make sure that the asset associated with the item is downloaded to your device! You can even watch the progress of download real-time!

UX flow

@buranmert
buranmert / WebViewController.m
Last active March 3, 2017 18:48
WebView contentSize inspection
#import "WebViewViewController.h"
#import <WebKit/WebKit.h>
@interface UIView (AGLayoutExtensions)
- (void)addSubviewWithPinnedEdges:(UIView *)subview;
@end
@implementation UIView (AGLayoutExtensions)
@buranmert
buranmert / MB_Autolayout.m
Created December 15, 2016 14:04
Autolayout helper
- (void)ag_addSubview:(UIView *)subview withInsets:(UIEdgeInsets)insets {
[self addSubview:subview];
[subview setTranslatesAutoresizingMaskIntoConstraints:NO];
[self addConstraintFromSubview:subview forAttribute:NSLayoutAttributeTop withConstant:insets.top];
[self addConstraintFromSubview:subview forAttribute:NSLayoutAttributeBottom withConstant:insets.bottom];
[self addConstraintFromSubview:subview forAttribute:NSLayoutAttributeLeft withConstant:insets.left];
[self addConstraintFromSubview:subview forAttribute:NSLayoutAttributeRight withConstant:insets.right];
}
- (BOOL)addConstraintFromSubview:(UIView *)subview forAttribute:(NSLayoutAttribute)attribute withConstant:(CGFloat)constantValue {
@buranmert
buranmert / replace_prefix.sh
Created August 2, 2016 16:13
Replace file prefixes in batch
# remove prefix
for file in *; do mv "$file" "$(echo "$file"|cut -c3-)"; done
# add prefix
for file in *; do mv "$file" {{{new_pre}}}"$file"; done
@buranmert
buranmert / ExampleViewController.m
Created June 23, 2016 15:47
Example View Controller for SDK
#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>
#import "AFNetworking.h"
static NSString * const DummyModelUUID = @"a1303fcf-e6e2-4741-a028-82db4d566068";
@interface ViewController () <AGTViewControllerProtocol>
@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator;
@property (weak, nonatomic) IBOutlet AGTView *ARView;
@buranmert
buranmert / subarray_with_given_sum.py
Created July 12, 2015 16:08
Subarray with given sum
#!/usr/bin/env/python
test_data = [3, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100]
test_goal = 5
def find_subsequence(data, goal):
temp = list(data)
depth = 1
while len(temp) > 0:
@buranmert
buranmert / MBTableViewController
Created June 25, 2015 13:24
A UITableViewController that has a UIView as its root view
//
// MBTableViewController.m
// MBTableViewController
//
// Created by Mert Buran on 20/06/2015.
// Copyright (c) 2015 Mert Buran. All rights reserved.
//
#import "MBTableViewController.h"
#import "CustomTableViewController.h" //just in case, you should use your own custom UITableViewController subclass