This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| set recipientName to "Hissain Khan" | |
| set recipientAddress to "[email protected]" | |
| set theSubject to "AppleScript Automated Email Sending" | |
| set theContent to "This email was sent using AppleScript! for testing" | |
| tell application "Mail" | |
| set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true} | |
| tell theMessage | |
| make new to recipient with properties {name:recipientName, address:recipientAddress} | |
| send | |
| end tell |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| set listWithLinks to {"google.com", "bing.com", "yahoo.com"} | |
| set listWithLabels to {"Google", "Bing", "Yahoo"} | |
| set dialogTitle to "Select & Go to open link" | |
| set buttonOK to "Go" | |
| set buttonCancel to "Cancel" | |
| set choosedLabels to choose from list (listWithLabels as list) with title dialogTitle OK button name buttonOK cancel button name buttonCancel with multiple selections allowed | |
| if false is choosedLabels then return | |
| repeat with i from 1 to number of items in choosedLabels | |
| set choosedLabel to item i of choosedLabels | |
| repeat with i from 1 to number of items in listWithLabels |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| echo "This is simplest bash command" | |
| #start of the apple script code | |
| osascript <<'END' | |
| set theAlertText to "Swiftlint is not installed" | |
| set theAlertMessage to "Download from https://github.com/realm/SwiftLint manually. Would you like to open link?" | |
| display alert theAlertText message theAlertMessage as critical buttons {"Cancel", "Open link"} default button "Open link" cancel button "Cancel" giving up after 60 | |
| set the button_pressed to the button returned of the result | |
| if the button_pressed is "Open link" then | |
| open location "https://github.com/realm/SwiftLint/blob/master/README.md" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun addDummyUser() { | |
| val apiService = RestApiService() | |
| val userInfo = UserInfo( id = null, | |
| userName = "Alex", | |
| userEmail = "[email protected]", | |
| userAge = 32, | |
| userUid = "164E92FC-D37A-4946-81CB-29DE7EE4B124" ) | |
| apiService.addUser(userInfo) { | |
| if (it?.id != null) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import retrofit2.Call | |
| import retrofit2.Callback | |
| import retrofit2.Response | |
| import retrofit2.Retrofit | |
| class RestApiService { | |
| fun addUser(userData: UserInfo, onResult: (UserInfo?) -> Unit){ | |
| val retrofit = ServiceBuilder.buildService(RestApi::class.java) | |
| retrofit.addUser(userData).enqueue( | |
| object : Callback<UserInfo> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import okhttp3.OkHttpClient | |
| import retrofit2.Retrofit | |
| import retrofit2.converter.gson.GsonConverterFactory | |
| object ServiceBuilder { | |
| private val client = OkHttpClient.Builder().build() | |
| private val retrofit = Retrofit.Builder() | |
| .baseUrl("http://api.server.com") // change this IP for testing by your actual machine IP | |
| .addConverterFactory(GsonConverterFactory.create()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import retrofit2.Call | |
| import retrofit2.http.Body | |
| import retrofit2.http.Headers | |
| import retrofit2.http.POST | |
| interface RestApi { | |
| @Headers("Content-Type: application/json") | |
| @POST("users") | |
| fun addUser(@Body userData: UserInfo): Call<UserInfo> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data class UserInfo ( | |
| @SerializedName("user_id") val userId: Int?, | |
| @SerializedName("user_name") val userName: String?, | |
| @SerializedName("user_email") val userEmail: String?, | |
| @SerializedName("user_age") val userAge: String?, | |
| @SerializedName("user_uid") val userUid: String? | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "user_id": 1001, | |
| "user_name": "Alex", | |
| "user_email": "[email protected]", | |
| "user_age": 32, | |
| "user_uid": "164E92FC-D37A-4946-81CB-29DE7EE4B124" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "user_name": "Alex", | |
| "user_email": "[email protected]", | |
| "user_age": 32, | |
| "user_uid": "164E92FC-D37A-4946-81CB-29DE7EE4B124" | |
| } |