Skip to content

Instantly share code, notes, and snippets.

View yongjhih's full-sized avatar
🏠
Working from home

Andrew Chen yongjhih

🏠
Working from home
View GitHub Profile
@MensObscura
MensObscura / CustomBottomNavigationView.java
Last active July 15, 2019 12:42
BottomNavigationView with shifModeDisable and Badge
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.support.design.internal.BottomNavigationItemView;
import android.support.design.internal.BottomNavigationMenuView;
import android.support.design.widget.BottomNavigationView;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseArray;
import android.view.Gravity;
@amihalik
amihalik / ParsingExample.java
Created May 31, 2017 16:50
A "Pre Java 8" and Java 8 example of parsing a date/time string
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
public class ParsingExample {
@collinjackson
collinjackson / main.dart
Last active August 17, 2023 20:06
PageView example with dots indicator
// Copyright 2017, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:math';
import 'package:flutter/material.dart';
void main() {
runApp(new MyApp());
}
@disintegrator
disintegrator / main.ts
Last active November 14, 2020 06:58
RxJS + Axios
import axios, { AxiosRequestConfig, AxiosResponse } from 'axios';
import { Observable } from 'rxjs';
const fromRequest = (request: AxiosRequestConfig) =>
new Observable<AxiosResponse>(
(o) => {
const source = axios.CancelToken.source();
o.add(() => source.cancel('Operation canceled by the user.'));
@jayrambhia
jayrambhia / GifItem.java
Last active June 24, 2017 12:09
GIF search engine with Litho and Giphy for Android
public class GifItem {
private final String id;
private final String image;
public GifItem(JsonObject json) {
this.id = json.get("id").getAsString();
JsonObject image = json.get("images").getAsJsonObject().get("original").getAsJsonObject();
this.image = image.get("url").getAsString();
}
@michaellihs
michaellihs / SemVer.groovy
Created April 12, 2017 21:42
Semantic Versioning class for Groovy
enum PatchLevel {
MAJOR, MINOR, PATCH
}
class SemVer implements Serializable {
private int major, minor, patch
SemVer(String version) {
def versionParts = version.tokenize('.')
@JorgeCastilloPrz
JorgeCastilloPrz / reader.kt
Last active December 30, 2017 10:26
reader sample for medium article
class Reader<C, out A>(val run: (C) -> A) {
inline fun <B> map(crossinline fa: (A) -> B): Reader<C, B> = Reader {
c -> fa(run(c))
}
inline fun <B> flatMap(crossinline fa: (A) -> Reader<C, B>): Reader<C, B> = Reader {
c -> fa(run(c)).run(c)
}
@marciogranzotto
marciogranzotto / MVP + Interactor example.kt
Last active November 4, 2020 15:40
This is an example of Android development with MVP + Interactor in Kotlin
interface LoginContracts {
interface View {
fun presentHomeScreen(user: User)
fun showError(message: String)
}
interface Presenter {
fun onDestroy()
fun onLoginButtonPressed(username: String, password: String)
}
@jimschubert
jimschubert / .gitignore
Last active March 27, 2025 09:49
Prototyping a Flags/Bitmasks implementation in Kotlin 1.1.1
META-INF/
*.class
@eagletmt
eagletmt / main.go
Last active August 19, 2024 22:54
List installable Android SDK packages (similar to sdkmanager --verbose --list)
package main
import (
"encoding/xml"
"fmt"
"io/ioutil"
"log"
"net/http"
)