Skip to content

Instantly share code, notes, and snippets.

View aidino's full-sized avatar

Dino aidino

  • 18:39 (UTC +07:00)
View GitHub Profile
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@aidino
aidino / googleSheetDropDown.gs
Created August 21, 2018 08:28
Dropdown google sheet
function onEdit() {
//Get active sheet
var activeSheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
if(activeSheet.getName() == "Transactions") {
Logger.log("onEdit Transactions sheet")
applyTransactionCategoryDropdown()
}
}
function applyTransactionCategoryDropdown() {
class MediaItem {
var name: String
init(name: String) {
self.name = name
}
}
class Movie: MediaItem {
var director: String
init(name: String, director: String) {
self.director = director
// Value type example
struct S {
var data: Int = -1
}
var a = S()
var b = a // a is copied to b
a.data = 42 // Changes a, not b
print("\(a.data), \(b.data)") //prints "42, -1"
// Reference type example
class C {
// Defining a Base Class
class Vehicle {
var currentSpeed = 0.0
var description: String {
return "traveling at \(currentSpeed) miles per hour"
}
func makeNoise() {
// do nothing - an arbitrary vehicle doesn't necessarily make a noise
}
}
@aidino
aidino / inout-example.swift
Created February 12, 2019 03:50
Inout example
func swapTwoInts(_ a: inout Int, _ b: inout Int) {
let temporaryA = a
a = b
b = temporaryA
}
var someInt = 3
var anotherInt = 107
swapTwoInts(&someInt, &anotherInt)
print("someInt is now \(someInt), and anotherInt is now \(anotherInt)")
<plist version="1.0">
<dict>
...
<key>FacebookAppID</key>
<string>{your-app-id}</string>
<key>FacebookDisplayName</key>
<string>{your-app-name}</string>
<key>AccountKitClientToken</key>
<string>{your-account-kit-client-token}</string>
<key>CFBundleURLTypes</key>
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
// Initialize Google sign-in
GIDSignIn.sharedInstance().clientID = "YOUR_CLIENT_ID" // get from Google Developer
// Initialize Facebook/AccountKit sign-in
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
return true
}
import Foundation
import UIKit
import GoogleSignIn
import FBSDKLoginKit
import AccountKit
typealias GoogleSignInResponse = (_ user: GIDGoogleUser?, _ error: Error?) -> ()
typealias FacebookSignInResponse = (_ result: FBSDKLoginManagerLoginResult?, _ error: Error?) -> ()
typealias AccountKitSignInResponse = (_ account: AKFAccount?, _ token: AKFAccessToken?,_ error: Error?) -> ()
import UIKit
import FBSDKLoginKit
class ViewController: UIViewController {
var socialSignInService: SocialSignInInterface = SocialSignInService()
override func viewDidLoad() {
super.viewDidLoad()
}