Skip to content

Instantly share code, notes, and snippets.

View indyfromoz's full-sized avatar
🏠
Working from home

Indrajit Chakrabarty indyfromoz

🏠
Working from home
View GitHub Profile
//
import SwiftUI
extension Notification.Name {
static let popEverything = Notification.Name("pop_everything")
}
struct MoreTabView: View {
@State var triggerNext: Bool = false
// Run any SwiftUI view as a Mac app.
import Cocoa
import SwiftUI
public func run<V: View>(view: V) {
let delegate = AppDelegate(view)
let app = NSApplication.shared
NSApp.setActivationPolicy(.regular)
app.mainMenu = app.customMenu
@indyfromoz
indyfromoz / breathe.swift
Created May 15, 2020 19:30 — forked from navsing/breathe.swift
let’s recreate the breathe app in less than 3 minutes using SwiftUI and Swift Playgrounds on iPad
struct Breathe: View {
@State var scale = false
@State var rotate = false
var body: some View {
ZStack {
Group {
ZStack {
Circle().frame(width: 80, height: 80).foregroundColor(Color(UIColor.systemBlue)).offset(y: -42)
Circle().frame(width: 80, height: 80).foregroundColor(Color(UIColor.systemBlue)).offset(y: 42)
@indyfromoz
indyfromoz / AppStoreHome.swift
Last active May 15, 2020 19:31 — forked from navsing/AppStoreHome.swift
Let’s recreate the iOS app store home screen in less than 5 minutes using SwiftUI and Swift Playgrounds on iPad
import SwiftUI
import PlaygroundSupport
struct Screen: View {
var body: some View {
ScrollView {
HStack {
VStack (alignment: .leading) {
Text("TUESDAY, MAY 12").foregroundColor(.secondary).bold().font(.footnote)
@indyfromoz
indyfromoz / MacEditorTextView.swift
Created May 26, 2020 19:09 — forked from unnamedd/MacEditorTextView.swift
[SwiftUI] MacEditorTextView - A simple and small NSTextView wrapped by SwiftUI.
/**
* MacEditorTextView
* Copyright (c) Thiago Holanda 2020
* https://twitter.com/tholanda
*
* MIT license
*/
import Combine
import SwiftUI
@indyfromoz
indyfromoz / gradle.properties
Created June 12, 2020 01:08
Gradle Properties file
# Put this in gradle/gradle.properties
org.gradle.parallel=true
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx4096M -Dkotlin.daemon.jvm.options\="-Xmx4096M"
@indyfromoz
indyfromoz / Twilio Asterisk Secure Trunking HOWTO.md
Created June 12, 2020 02:15 — forked from ianthetechie/Twilio Asterisk Secure Trunking HOWTO.md
A short guide on how to set up an encrypted VoIP system using Twilio and Asterisk.

Twilio Asterisk Secure Trunking HOWTO

This is a short guide on how to set up an encrypted VoIP system using Twilio and Asterisk. I was a little annoyed that just about everything these days still uses unencrypted RTP for media (though just about everyone supports SIP over TLS). So I spent a weekend looking at options, and settled on a totally overkill solution involving Twilio's secure trunking to an Asterisk PBX. While all bets are off once it hits the PSTN, at least you won't be blasting your conversations over the internet in clear text.

// I needed to fetch all the pages from a paged endpoint.
// In this specific case, the JSON results contained a `pagingStatus` section that provided extra information which I could use:
// Hiding that behind a protocol:
import Foundation
protocol PagedReturning {
var pagingStatus: PagingStatus { get }
}
@indyfromoz
indyfromoz / CustomBackButton.swift
Last active July 1, 2020 10:17
A custom back button for use as leftBarButtonItem (Useful for cases when the navigationItem.title of parent view controller can not be changed)
let chevron = UIImage(systemName: "chevron.left", withConfiguration: UIImage.SymbolConfiguration(pointSize: 18, weight: .semibold))
let button = UIButton(type: .system)
button.setImage(chevron?.withRenderingMode(.alwaysTemplate), for: .normal)
button.setImage(chevron?.withRenderingMode(.alwaysTemplate), for: .selected)
button.setImage(chevron?.withRenderingMode(.alwaysTemplate), for: .focused)
button.tintColor = UIColor.darkPinkPrimary
button.setTitle("Back", for: .normal)
button.titleLabel?.font = .systemFont(ofSize: 18)
button.titleEdgeInsets = UIEdgeInsets(top: 0.0, left: 2.0, bottom: 0.0, right: -2.0)
button.contentEdgeInsets = .init(top: 0, left: -8, bottom: 0, right: 0)
import SwiftUI
import PlaygroundSupport
struct Desktop: View {
var body: some View {
ZStack {
// Image(uiImage: #imageLiteral(resourceName: "IMG_6281.JPG"))
Color(UIColor.systemBlue)
macOS()
}