Skip to content

Instantly share code, notes, and snippets.

View ugommirikwe's full-sized avatar

Ugo ugommirikwe

View GitHub Profile
@ugommirikwe
ugommirikwe / mixin-rgba.less
Last active August 29, 2015 14:21 — forked from anonymous/gist:4169726
CSS LESS Mixin for applying background color using the RGBA expression.
.rgba(@colour, @alpha) {
@alphaColour: hsla(hue(@colour), saturation(@colour), lightness(@colour), @alpha);
@ieAlphaColour: argb(@alphaColour);
background-color: @colour; // Fallback for older browsers
// IE hacks
zoom: 1; // hasLayout
background-color: transparent\9;
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=@{ieAlphaColour}, endColorstr=@{ieAlphaColour})"; // IE 8+
@ugommirikwe
ugommirikwe / res_color_btn_flat_selector.xml
Last active August 29, 2015 14:22 — forked from dmytrodanylyk/res_color_btn_flat_selector.xml
Android Material (Flat) Button style themeing code snippets
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false"
android:color="@color/flat_disabled_text"/>
<item android:color="@color/flat_normal_text"/>
</selector>
@ugommirikwe
ugommirikwe / ApiService.java
Created September 29, 2015 08:33 — forked from dustin-graham/ApiService.java
Infinite Scrolling Android RecyclerView with RxJava
public static Observable<List<String>> paginatedThings(final Observable<Void> onNextObservable) {
return Observable.create(new Observable.OnSubscribe<List<String>>() {
@Override
public void call(final Subscriber<? super List<String>> subscriber) {
onNextObservable.subscribe(new Observer<Void>() {
int latestPage = -1;
@Override
public void onCompleted() {
subscriber.onCompleted();
@ugommirikwe
ugommirikwe / isEmpty.js
Created February 7, 2019 21:15
Utility function to coerce a value of any native JavaScript data type to a boolean representation.
function isEmpty(data) {
if (typeof data === 'number' || typeof data === 'boolean') {
return false
}
if (typeof data === 'undefined' || data === null) {
return true
}
if (typeof data.length !== 'undefined') {
@ugommirikwe
ugommirikwe / isValidCssSelector.js
Created February 7, 2019 21:19
Utility Javascript function to check if a provided value is a valid CSS selector string.
function isValidCssSelector(selector) {
var re = /^[A-Za-z]+[\w\-\:\.]*$/
return re.test(id)
}
@ugommirikwe
ugommirikwe / querystring.swift
Created February 27, 2019 08:34 — forked from gillesdemey/querystring.swift
Retrieve specific query string parameter from NSURL
func getQueryStringParameter(url: String, param: String) -> String? {
let url = NSURLComponents(string: url)!
return
(url.queryItems? as [NSURLQueryItem])
.filter({ (item) in item.name == param }).first?
.value()
}
@ugommirikwe
ugommirikwe / ios_android.dart
Created August 8, 2019 14:01 — forked from slightfoot/ios_android.dart
Example of using defaultTargetPlatform to change the entire widget tree based on platform.
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
void main() {
//runApp(IOSApp());
//runApp(AndroidApp());
runApp(defaultTargetPlatform == TargetPlatform.iOS ? IOSApp() : AndroidApp());
}
@ugommirikwe
ugommirikwe / CoroutineTestRule.kt
Created April 24, 2020 13:12 — forked from AniketSK/CoroutineTestRule.kt
A test rule to allow testing coroutines that use the main dispatcher. Without this you'd run into "java.lang.IllegalStateException: Module with the Main dispatcher had failed to initialize. For tests Dispatchers.setMain from kotlinx-coroutines-test module can be used"
package com.aniketkadam.sharevideoshortcut
import org.junit.rules.TestWatcher
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.TestCoroutineDispatcher
import kotlinx.coroutines.test.resetMain
import kotlinx.coroutines.test.setMain
import org.junit.runner.Description
@ugommirikwe
ugommirikwe / MainActivity.kt
Last active May 1, 2021 09:58
Here's how you would implement a permission request/validation in a Jetpack Compose app. Note the code was to intended for embedding a MapBox map, but there are some other code related to using the MapBox map that are not shown here. This code snippet is just for requesting permissions in a Compose UI app. This solution was inspired by: https://…
package io.ugommirikwe.app
import android.Manifest
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Bundle
import android.provider.Settings
import androidx.activity.compose.LocalActivityResultRegistryOwner
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
fastlane_require 'dotenv'
default_platform(:android)
platform :android do
# Have an easy way to get the root of the project
def root_path
Dir.pwd.sub(/.*\Kfastlane/, '').sub(/.*\Kandroid/, '').sub(/.*\Kios/, '').sub(/.*\K\/\//, '')
end