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
@cdriehuys
cdriehuys / Axios Nock and Typescript.md
Last active October 2, 2024 10:03
Typescript definition file to make axios work with nock

Axios, Nock, and Typescript

There is a documented issue describing how axios and nock do not work well together. The workaround described in this comment works.

import axios from 'axios';
import httpAdapter from 'axios/lib/adapters/http';
import nock from 'nock';

axios.defaults.adapter = httpAdapter;
@stephenjfox
stephenjfox / LedgerActivities.kt
Last active September 23, 2023 19:37
Parse XML in Kotlin with Jackson
import com.fasterxml.jackson.annotation.JsonAlias
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.annotation.JsonRootName
import java.util.*
data class LedgerActivityDetail(
@set:JsonProperty("TransactionType")
var loanType: String? = null,
Material(
elevation: 4.0,
shape: CircleBorder(),
clipBehavior: Clip.hardEdge,
color: Colors.transparent,
child: Ink.image(
image: AssetImage('assets/profile_default.jpg'),
fit: BoxFit.cover,
width: 120.0,
height: 120.0,
@nic0lette
nic0lette / MainActivity.kt
Created May 25, 2018 23:58
Example of using AccountManager.newChooseAccountIntent without GET_ACCOUNTS permission
/*
* Copyright 2018 Google LLC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@ArthurNagy
ArthurNagy / RoundedBottomSheetDialogFragment.kt
Last active March 10, 2025 08:53
Rounded modal bottom sheet as seen in new Google products(Tasks, News, etc.), described in this article: https://medium.com/halcyon-mobile/implementing-googles-refreshed-modal-bottom-sheet-4e76cb5de65b
package com.your.package
import android.app.Dialog
import android.os.Bundle
import com.your.package.R
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
/**
* BottomSheetDialog fragment that uses a custom
@kentcb
kentcb / reactive_refresh_indicator.dart
Last active February 17, 2021 02:21
A better RefreshIndicator for flutter
// Copyright 2014 The Chromium Authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// Sample JSON
// { "bar": "hello world" }
// The Foo class
@JsonClass(generateAdapter = true)
data class Foo(
val bar: String
)
// Generated by Moshi Kotlin Code Gen
@LouisCAD
LouisCAD / LifecycleCoroutines.kt
Last active July 3, 2022 11:47
CoroutineScope and Job integration with Lifecycle for Android. Meant to be used for your coroutines in lifecycle aware components. OUTDATED. See up to date implementation here: https://github.com/LouisCAD/Splitties/tree/master/modules/lifecycle-coroutines
import android.arch.lifecycle.GenericLifecycleObserver
import android.arch.lifecycle.Lifecycle
import android.arch.lifecycle.Lifecycle.Event.ON_DESTROY
import android.arch.lifecycle.LifecycleOwner
import kotlinx.coroutines.experimental.CoroutineScope
import kotlinx.coroutines.experimental.Dispatchers
import kotlinx.coroutines.experimental.Job
import kotlinx.coroutines.experimental.android.Main
fun Lifecycle.createJob(cancelEvent: Lifecycle.Event = ON_DESTROY): Job {
@RecuencoJones
RecuencoJones / pagination-blocking.js
Last active November 1, 2018 22:10
RxJS pagination
const { create, of, fromPromise } = Rx.Observable
////// main //////
const charactersUrl = 'https://swapi.co/api/people'
const getAllCharacters = () => getPagedResource(charactersUrl)
// outputs all characters at once
getAllCharacters()
.subscribe((vals) => {
@putraxor
putraxor / rich_text_view.dart
Created April 25, 2018 05:59
Flutter rich text view with clickable hyperlink
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart' as launcher;
///TODO: check performance impact bro !!!
class LinkTextSpan extends TextSpan {
LinkTextSpan({TextStyle style, String url, String text})
: super(
style: style,