Skip to content

Instantly share code, notes, and snippets.

@quwac
quwac / diff-pre-commit.sh
Last active February 1, 2023 01:44
pre-commit for git diff commits
#!/bin/bash
set -eu
# main vs HEAD
CHANGED_FILES="$(git diff --name-only --diff-filter=d origin/main...HEAD | awk '{print $1}' | tr '\n' ' ')"
if [ -n "$CHANGED_FILES" ]; then
pre-commit run --files $CHANGED_FILES
else
echo No files changed.
@quwac
quwac / google_api_utils.py
Last active June 20, 2022 02:29
Authentication/Authorization code for Google API using Python
import configparser
import contextlib
import json
import os
import pickle
import sqlite3
import urllib.parse
from typing import Any, Dict, List, Optional, Tuple, Union
import google.auth.credentials
@quwac
quwac / 00_PauseHandler_for_Handler_post_method_README.md
Created September 6, 2020 03:37
PauseHandler for Handler#post method

PauseHandler for Handler#post method

PauseHandler is a good solution for cancelling or saving requested message on an activities lifecycle.

However requested actions by post method cannot be cancelled or saved because original PauseHandle class is overridden handleMessage.

This modified PauseHandler is overridden dispatchMessage so the actions by post method can be cancelled or saved.

@quwac
quwac / CachedLiveData.kt
Created August 30, 2020 05:24
CachedLiveData with SavedStateHandle extension
//
// Title: CachedLiveData
// Author: quwac (https://github.com/quwac)
// License: CC0 (https://creativecommons.org/publicdomain/zero/1.0/deed.en)
//
package io.github.quwac.cachedlivedata
import androidx.lifecycle.*