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 Double.round(decimals: Int): Double { | |
var multiplier = 1.0 | |
repeat(decimals) { multiplier *= 10 } | |
return round(this * multiplier) / multiplier | |
} |
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 java.text.ParseException | |
import java.text.SimpleDateFormat | |
import java.util.* | |
// Converting from String to Date | |
fun String.getDateWithServerTimeStamp(): Date? { | |
val dateFormat = SimpleDateFormat( | |
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", | |
Locale.ENGLISH) |
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 android.view.View | |
import it.diceworld.dicehome.utility.OnSingleClickListener | |
fun View.setGone(){ | |
this.visibility = View.GONE | |
} | |
fun View.setVisible(){ | |
this.visibility = View.VISIBLE | |
} |
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
/** | |
* Take the Long milliseconds returned by the system and stored in Room, | |
* and convert it to a nicely formatted string for display. | |
* | |
* EEEE - Display the long letter version of the weekday | |
* MMM - Display the letter abbreviation of the nmotny | |
* dd-yyyy - day in month and full year numerically | |
* HH:mm - Hours and minutes in 24hr format | |
*/ | |
@SuppressLint("SimpleDateFormat") |
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
private val exceptionHandler = CoroutineExceptionHandler { _, exception -> | |
LogHelper.log(TAG, "User Observer Exception: ${exception.stackTrace}", Log.ERROR) | |
} | |
private suspend fun userHasClientCodes(user : FirebaseUser, request: UsersRequest, token : String): String? = | |
withContext(Dispatchers.IO+ exceptionHandler) { | |
val response = CustomerAreaAPI.createUser(request, "Bearer ${token}") | |
if (response != null && response !is String) { | |
if (AppPreferences.firstTimeNotification == 0) { | |
AppPreferences.firstTimeNotification = 1 |
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
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS) | |
intent.setData(Uri.parse("package:" + getString(R.string.app_package))); | |
startActivity(intent); |
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
#include <stdio.h> | |
#include <stdlib.h> | |
/* The calling function takes a single callback as a parameter. */ | |
void PrintTwoNumbers(int (*numberSource)(void)) { | |
int val1 = numberSource(); | |
int val2 = numberSource(); | |
printf("%d and %d\n", val1, val2); | |
} |
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
/* | |
* This is a simple C program to demonstrate the usage of callbacks | |
* The callback function is in the same file as the calling code. | |
* The callback function can later be put into external library like | |
* e.g. a shared object to increase flexibility. | |
* | |
*/ | |
#include <stdio.h> | |
#include <string.h> |
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
<!DOCTYPE html> | |
<html> | |
<title>Web Page Design</title> | |
<head> | |
<script> | |
function calculate(num1, num2, callbackFunction) { | |
return callbackFunction(num1, num2); | |
} | |
function calcProduct(num1, num2) { |
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
def get_square(val): | |
"""The callback.""" | |
return val ** 2 | |
def caller(func, val): | |
return func(val) | |
caller(get_square, 5) | |
print caller(get_square, 5) |