Skip to content

Instantly share code, notes, and snippets.

View valokafor's full-sized avatar

Val Okafor valokafor

View GitHub Profile
@valokafor
valokafor / LocaldateConverter.kt
Created February 14, 2024 19:56
Room Converter for Local Date
class LocalDateConverter {
@TypeConverter
fun fromTimestamp(value: Long): LocalDate? {
return if (value < 0) null
else Instant.ofEpochMilli(value)
.atZone(ZoneId.systemDefault())
.toLocalDate()
}
@valokafor
valokafor / gist:b5f8acf1169827e7c88cc813940a384e
Created December 11, 2023 17:43
CustomOutlinedText Field
//How to use
CustomOutlinedText(
textValue = uiState.email,
testTag = "username_field",
hintTextId = R.string.hint_enter_email,
labelTextId = R.string.hint_email,
keyboardOptions = KeyboardOptions.Default.copy(
keyboardType = KeyboardType.Email,
imeAction = ImeAction.Next
),
@valokafor
valokafor / SampleData.kt
Created April 3, 2023 00:12
Sample data for Pronto Todo List App
object SampleData {
fun getSampleTasks(): List<TaskModel> {
return listOf(
TaskModel(
title = "Complete project proposal",
dueDate = LocalDate.parse("2023-02-25"),
priority = Priority.HIGH,
hasReminder = true,
isCompleted = false,
createdDate = LocalDateTime.now(),
package com.theozgurr.apparchitecture.ui.register
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.onRoot
import androidx.navigation.NavHostController
package com.theozgurr.apparchitecture.common
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performTextInput
import androidx.test.ext.junit.rules.ActivityScenarioRule
import com.theozgurr.apparchitecture.ui.MainActivity
@valokafor
valokafor / fragment_login.xml
Created December 14, 2021 06:39
Sample Layout File for Login Screen
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:fillViewport="true"
android:paddingStart="@dimen/dp_32"
android:paddingEnd="@dimen/dp_32"
@valokafor
valokafor / check_url.java
Created August 18, 2018 18:53
Url Validator
/**
* Recursive method for resolving redirects. Resolves at most MAX_REDIRECTS times.
*
* @param url a URL
* @param remainingRedirects loop counter
* @return instance of URLConnection
* @throws IOException if connection fails
*/
protected boolean createConnection(URL url, int remainingRedirects) throws IOException {
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Troypoint</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<html>
<head>
<title>aa</title>
<script src="script.js" ></script>
<body>
<input id="totalPrice" />
<button type="button" onclick="calculateTotal()">
Calculate
function calculateTotal(){
var price = parseFloat(document.getElementById("totalPrice").value);
var tax = price * 8.4 / 100;
var totalPrice = price + tax;
alert("Total price: " + totalPrice);
}