Skip to content

Instantly share code, notes, and snippets.

@afinarv
afinarv / negaraUSA.json
Created July 22, 2021 16:03
Try to make a json gist
[
{
"name": "Alabama",
"abbreviation": "AL"
},
{
"name": "Alaska",
"abbreviation": "AK"
},
{
@afinarv
afinarv / playlist.json
Last active July 22, 2021 17:03
Sepotipai Playlist
[
{
"id": 0,
"singer": "Ciara",
"title": "Level Up"
},
{
"id": 1,
"singer": "U2",
"title": "Elevation"
if #available(iOS 11, *) {
self.clipsToBounds = true
self.layer.cornerRadius = radius
var masked = CACornerMask()
if corners.contains(.topLeft) { masked.insert(.layerMinXMinYCorner) }
if corners.contains(.topRight) { masked.insert(.layerMaxXMinYCorner) }
if corners.contains(.bottomLeft) { masked.insert(.layerMinXMaxYCorner) }
if corners.contains(.bottomRight) { masked.insert(.layerMaxXMaxYCorner) }
self.layer.maskedCorners = masked
} else {
func createNavController(root: UIViewController) -> UINavigationController{
let navController = UINavigationController(rootViewController: root)
navController.navigationBar.layer.masksToBounds = false
navController.navigationBar.layer.shadowColor = UIColor.lightGray.cgColor
navController.navigationBar.layer.shadowOpacity = 0.5
navController.navigationBar.layer.shadowOffset = CGSize(width: 0, height: 2.0)
navController.navigationBar.layer.shadowRadius = 5
return navController
}
class MainTabBarController: UITabBarController {
var homeViewController: HomeViewController!
var secondViewController: MarketplaceViewController!
var serviceViewController: PartnerListViewController!
var actionViewController: UIViewController!
var thirdViewController: JobListViewController!
var fourthViewController: MenuViewController!
override func viewDidLoad() {
@afinarv
afinarv / AudioHelper.swift
Created October 24, 2021 16:35
AudioHelper to simplify audio
import Foundation
import AVFoundation
class AudioHelper: NSObject, AVAudioPlayerDelegate {
var player: AVAudioPlayer?
class var defaultHelper: AudioHelper {
struct Static {
static let instance: AudioHelper = AudioHelper()
}
@afinarv
afinarv / SwiftConditionIntro.swift
Created March 30, 2022 00:31
Learning basic condition & function in Swift
var today = "Wednesday"
//1. if
if today == "Friday" {
print("Play 'Last Friday Night' by Katy Perry")
}
//2. if-else
if today == "Friday" {
print("Play 'Last Friday Night' by Katy Perry")
import UIKit
/* 1.
Some people LOVE music. They listen to music almost all the time, more than 50 times per day. Let's call them the 'Music Junkie'.
Some other occasionally listen to music. They listen to music 10 to 50 times per day. Let's call them the 'Music Enjoyer'.
And some other choose not to have music at all. So, zero times. Let's call them 'No-music Folk'.
|-------------------- |--------------------------------- |
|numberOfPlayedMusic | Print Result |
|-------------------- |--------------------------------- |
/* 1.
This is the lyric of Finger Family:
-----
daddy finger, daddy finger
where are you?
here I am, here I am
how do you do?
mommy finger, mommy finger
/*
This is the lyric of Baby Shark:
-----
Baby shark, doo doo doo doo doo doo
Baby shark, doo doo doo doo doo doo
Baby shark, doo doo doo doo doo doo
Baby shark!
Mommy shark, doo doo doo doo doo doo
Mommy shark, doo doo doo doo doo doo