Skip to content

Instantly share code, notes, and snippets.

Avatar

Pascal Welsch passsy

View GitHub Profile
@passsy
passsy / const_uri.dart
Last active Mar 16, 2021
const implemenation of dart:core Uri
View const_uri.dart
// @dart=2.12
/// A const implementation of Uri which crashes at first access in case the uri is invalid
class ConstUri implements Uri {
/// Caches the static parsed uri
///
/// The parsed uri can't be a mutable member field because that's not allowed for const classes
static final _cache = <String, Uri>{};
const ConstUri(String uri) : _uri = uri;
@passsy
passsy / material text sizes.md
Last active Jan 22, 2021
Material font sizes
View material text sizes.md
@passsy
passsy / build.gradle
Last active Jan 15, 2021
lazy jake wharton versioning
View build.gradle
def versionMajor = 3
def versionMinor = 0
def versionPatch = 0
def versionBuild = 0 // bump for dogfood builds, public betas, etc.
android {
defaultConfig {
versionCode versionMajor * 10000 + versionMinor * 1000 + versionPatch * 100 + versionBuild
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
}
@passsy
passsy / BasicNetwork.java
Created Jul 8, 2013
BasicNetwork fix for Volley with fallback to Cache if the device is offline
View BasicNetwork.java
/*
* Copyright (C) 2011 The Android Open Source Project
*
* 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
@passsy
passsy / KIntent.kt
Last active Sep 29, 2020
Kotlin extension functions to start a generic Activity
View KIntent.kt
package com.pascalwelsch.extensions
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.Bundle
/**
* Extensions for simpler launching of Activities
@passsy
passsy / README.md
Last active Jul 24, 2020
How to use xrechnung-visualization
View README.md

How to use xrechnung-visualization

1. Install Ant

Install brew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Then install ant using brew

@passsy
passsy / main.dart
Created Jun 17, 2020
wrap_content match_parent in Flutter
View main.dart
import 'package:flutter/material.dart';
Future<void> main() async {
runApp(Builder(
builder: (context) => const MyApp(),
));
}
class MyApp extends StatelessWidget {
const MyApp({
@passsy
passsy / Locale.kt
Last active May 28, 2020
Allows easy iteration about all available locales. Kotlin Collection implementation for LocaleList which doesn't implement Collection<Locale> itself.
View Locale.kt
package com.pascalwelsch.android.util
import android.content.Context
import androidx.core.os.ConfigurationCompat
import androidx.core.os.LocaleListCompat
import java.util.Locale
/**
* Returns an [Iterable] for the languages of the user, sorted by priority. First choice first.
*/
@passsy
passsy / main.dart
Created Apr 23, 2020
Type switch case
View main.dart
void main() {
final Object something = TypeA();
something.matchTypes({
TypeA : () => print("found A"),
TypeB : () => print("found B"),
});
}
@passsy
passsy / ArrayAdapter.java
Last active Apr 21, 2020
ArrayAdapter for RecyclerView
View ArrayAdapter.java
package com.pascalwelsch.utils;
import android.support.annotation.Nullable;
import android.support.v7.util.DiffUtil;
import android.support.v7.widget.RecyclerView;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;