Skip to content

Instantly share code, notes, and snippets.

View cjae's full-sized avatar

Osagie Omon cjae

View GitHub Profile
@cjae
cjae / PageIndicator.kt
Last active October 21, 2023 11:08
Pager indicator with tracking crossfade animation effect.
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.width
/* Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
public class LiveDataTestUtil {
public static <T> T getOrAwaitValue(final LiveData<T> liveData) throws InterruptedException {
final Object[] data = new Object[1];
final CountDownLatch latch = new CountDownLatch(1);
Observer<T> observer = new Observer<T>() {
@Override
public void onChanged(@Nullable T o) {
data[0] = o;
public class CardPaymentActivity extends BaseActivity {
@BindView(R.id.cardNumberView)
TextFieldBoxes cardNumberView;
@BindView(R.id.cardMonthView)
TextFieldBoxes cardMonthView;
@BindView(R.id.cardYearView)
TextFieldBoxes cardYearView;
@cjae
cjae / DiagonalDifference.java
Created February 27, 2018 09:12
Solution to Hackerrank Diagonal Difference
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
static int diagonalDifference(int[][] a) {
// Complete this function
@cjae
cjae / iOSDateFormatter.swift
Last active February 21, 2018 10:18
Sample code to properly format Sql timestamp in JSON from a web service.
// Language: Swift 4
func getDayFromSqlTime(timeStamp: String) -> String {
let dateFormatter = DateFormatter()
/*
This format is based on what is returned from the webservice. My webservice returns "2018-12-12 20:19:22".
Every character has to be represented for this to work properly else Xcode would throw an error.
For example if your webservice returns "2018-02-21T10:10:14", then valid format would be "yyyy-MM-dd'T'HH:mm:ss",
if "2018-02-02 06:50:16 +0000", then format is "yyyy-MM-dd HH:mm:ss +zzzz".
*/