Skip to content

Instantly share code, notes, and snippets.

View Cliabhach's full-sized avatar

Philip Cohn-Cort Cliabhach

View GitHub Profile
@Cliabhach
Cliabhach / cat.dart
Last active May 2, 2022 07:50
Testing out interaction between Dart Futures and Dart Isolates
/// SPDX-License-Identifier: Apache-2.0
/// Based on source code in https://levelup.gitconnected.com/fluttering-dart-futures-and-isolates-6b4bce6d804b
import 'dart:math';
import 'dart:isolate';
class Cat {
var index;
var meowDelay;
@Cliabhach
Cliabhach / icon.svg
Last active April 8, 2020 19:53
SVG asset for Google Meet extension
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Cliabhach
Cliabhach / LizardCsvParser.groovy
Last active February 4, 2020 02:51
Parser for Lizard Code Quality Analysis, compatible with the Jenkins 'Warnings Next Generation' plugin
// Based on the excellent Jenkins guide at https://github.com/jenkinsci/warnings-ng-plugin/blob/538747e1a14974be5/doc/Documentation.md#creating-a-new-tool-using-a-groovy-parser
// This file may be used in accordance with the MIT-style license found at https://github.com/jenkinsci/warnings-ng-plugin/blob/master/LICENSE
import edu.hm.hafner.analysis.Severity
// CSV format is as follows (c.f. https://github.com/terryyin/lizard/blob/debd579ef16ae3c649/test/testOutputCSV.py#L25 )
// "NLOC,CCN,token,PARAM,length,location,file,function,long_name,start,end"
//
// Regex should look something like
//
package com.google.android.material.textfield
import android.content.Context
import android.util.AttributeSet
import android.view.ActionMode
import androidx.annotation.AttrRes
/**
* Variant of [TextInputEditText] that does not crash on
Caused by: java.io.UncheckedIOException: java.nio.charset.MalformedInputException: Input length = 1
at com.android.ide.common.symbols.SymbolIo.readWithPackage(SymbolIo.java:205)
at com.android.ide.common.symbols.SymbolIo.readSymbolListWithPackageName(SymbolIo.java:182)
at com.android.ide.common.symbols.SymbolUtils.loadDependenciesSymbolTables(SymbolUtils.kt:184)
at com.android.builder.symbols.SymbolExportUtils.processLibraryMainSymbolTable(SymbolExportUtils.kt:82)
at com.android.build.gradle.internal.res.GenerateLibraryRFileTask.doFullTaskAction(GenerateLibraryRFileTask.kt:110)
at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:106)
Web url: https://android.googlesource.com/platform/tools/base/+/studio-master-dev/sdk-common/src/main/java/com/android/ide/common/symbols/SymbolIo.java
/**
* Copyright 2019 Philip Cohn-Cort
*
* 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
@Cliabhach
Cliabhach / enum naming.patch
Created July 26, 2019 04:12
Minor adjustment to enum vars created by OpenAPI-Generator
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java
index 9e5e01123d..255e03f538 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java
@@ -531,6 +531,11 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
return varName;
}
+ // If the name is all uppercase and underscores now, leave it alone.
+ if (name.matches("^[A-Z_]*$")) {
@Cliabhach
Cliabhach / API 28 crash loop
Created April 9, 2019 16:26
Android telecom crash log
04-08 18:55:20.863 19707 21123 I Telecom : PhoneAccountRegistrar: Modify account: [ComponentInfo{com.android.phone/com.android.services.telephony.TelephonyConnectionService}, ***, UserHandle{0}]: TSI.rPA@M6k
04-08 18:55:20.944 19707 19853 I Telecom : PhoneAccountRegistrar: Modify account: [ComponentInfo{com.android.phone/com.android.services.telephony.TelephonyConnectionService}, ***, UserHandle{0}]: TSI.rPA@M64
04-08 18:55:20.947 19972 19972 I chatty : uid=1001(radio) com.android.phone expire 29 lines
04-08 18:55:21.016 19707 19853 I Telecom : PhoneAccountRegistrar: Modify account: [ComponentInfo{com.android.phone/com.android.services.telephony.TelephonyConnectionService}, ***, UserHandle{0}]: TSI.rPA@M7M
04-08 18:55:24.748 19707 19853 I Telecom : PhoneAccountRegistrar: Modify account: [ComponentInfo{com.android.phone/com.android.services.telephony.TelephonyConnectionService}, ***, UserHandle{0}]: TSI.rPA@M7o
04-08 18:55:24.802 19707 19795 E NetworkPolicy: Missing subscriberId for subId 1
04-08 18:55:24.802
@Cliabhach
Cliabhach / git-logrange
Last active January 16, 2019 18:40
Git log, with date range
#!/bin/bash
###
# Licensed under CC-BY-SA 4.0 by Philip Cohn-Cort
#
# Feel free to comment here on the GitHub Gist if you have feedback or
# want to use this. I wrote it up to sort of refresh my knowledge of
# Awk and Git formatting, so I wouldn't exactly recommend this for
# production usage as is.
#
@Cliabhach
Cliabhach / NullRemover.java
Created August 4, 2016 18:12
Remove null values from a JSONObject or JSONArray
public class NullRemover {
public void removeNullsFrom(@Nullable JSONObject object) throws JSONException {
if (object != null) {
Iterator<String> iterator = object.keys();
while (iterator.hasNext()) {
String key = iterator.next();
Object o = object.get(key);
if (o == null || o == JSONObject.NULL) {
iterator.remove();
} else {