Skip to content

Instantly share code, notes, and snippets.

View bubudrc's full-sized avatar

Marcelo Perretta bubudrc

View GitHub Profile
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Write: /bin/bash in 'Shell' input
# 5. Paste code below in to new "Run Script" section
# 6. Drag the "Run Script" below "Link Binaries With Libraries"
# 7. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)
@bubudrc
bubudrc / CurrentTopVC.m
Created September 17, 2015 15:30 — forked from snikch/gist:3661188
Find the current top view controller for your iOS application
- (UIViewController *)topViewController{
return [self topViewController:[UIApplication sharedApplication].keyWindow.rootViewController];
}
- (UIViewController *)topViewController:(UIViewController *)rootViewController
{
if (rootViewController.presentedViewController == nil) {
return rootViewController;
}
@bubudrc
bubudrc / iOS and Objective-C snippets.md
Created February 3, 2016 17:16 — forked from robbdimitrov/iOS and Objective-C snippets.md
Useful iOS and Objective-C snippets

iOS and Objective-C snippets

Move content from underneath the navigationBar (iOS 7)

if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) {
    [self setEdgesForExtendedLayout:UIRectEdgeRight|UIRectEdgeBottom|UIRectEdgeLeft];
}

Change the color of the back arrow in navigationBar (iOS 7)

import SwiftUI
import PlaygroundSupport
struct Desktop: View {
var body: some View {
ZStack {
// Image(uiImage: #imageLiteral(resourceName: "IMG_6281.JPG"))
Color(UIColor.systemBlue)
macOS()
}
//
// ContentView.swift
//
//
// Created by Bernstein, Joel on 7/4/20.
//
import SwiftUI
struct ElementModel: Identifiable
@bubudrc
bubudrc / nstask.swift
Created July 15, 2020 16:12 — forked from Seasons7/nstask.swift
NSTask Sample for Swift
import Cocoa
import Foundation
var str = "Hello, playground"
var task:NSTask = NSTask()
var pipe:NSPipe = NSPipe()
task.launchPath = "/bin/ls"
task.arguments = ["-la"]
@bubudrc
bubudrc / nstask.swift
Created July 15, 2020 16:12 — forked from Seasons7/nstask.swift
NSTask Sample for Swift
import Cocoa
import Foundation
var str = "Hello, playground"
var task:NSTask = NSTask()
var pipe:NSPipe = NSPipe()
task.launchPath = "/bin/ls"
task.arguments = ["-la"]
@bubudrc
bubudrc / Middleware
Created September 22, 2021 18:55 — forked from bballentine/Middleware
Vapor - Example middleware that checks user's role before giving access to protected resources.
import Vapor
import HTTP
public class AdminAuthMiddleware: Middleware {
public let error: Error
public let authLevel: UserRole
public init(error: Error, authLevel: UserRole) {
self.error = error
self.authLevel = authLevel
}
@bubudrc
bubudrc / deploy.swift
Created November 18, 2021 21:50 — forked from 0xTim/deploy.swift
A Swift script to deploy an app (in this case Vapor) to AWS Fargate from scratch. It first checks to see if there's a repository in ECR for the app, if not it creates one, builds the container and pushes it. It then checks for a registered task definition. In one doesn't exist in ECS, it updates the provided task definition with the latest ECR i…
#!/usr/bin/swift
import Foundation
// MARK: - Script variables
let awsProfileName: String? = "myProfile"
let serviceName = "someService"
// MARK: - Functions
@discardableResult
func shell(_ args: String..., returnStdOut: Bool = false, stdIn: Pipe? = nil) -> (Int32, Pipe) {
@bubudrc
bubudrc / 1_JSONifyTag.swift
Created December 10, 2021 14:49 — forked from vzsg/1_JSONifyTag.swift
Custom Leaf tag for printing anything in the context as JSON (Vapor 4)
import LeafKit
final class JSONifyTag: UnsafeUnescapedLeafTag {
func render(_ ctx: LeafContext) throws -> LeafData {
guard let param = ctx.parameters.first else {
throw "no parameter provided to JSONify"
}
return LeafData.string(param.jsonString)
}