Skip to content

Instantly share code, notes, and snippets.

View sebaslogen's full-sized avatar

Sebas LG sebaslogen

View GitHub Profile
@zach-klippenstein
zach-klippenstein / SegmentedControl.kt
Last active May 3, 2024 11:15
iOS-style segmented control in Compose
import android.annotation.SuppressLint
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.awaitFirstDown
import androidx.compose.foundation.gestures.forEachGesture
import androidx.compose.foundation.gestures.horizontalDrag
import androidx.compose.foundation.layout.Arrangement.spacedBy
import androidx.compose.foundation.layout.Box
@Comevius
Comevius / no_splash_factory.dart
Created December 3, 2019 07:15
NoSplashFactory
class NoSplashFactory extends InteractiveInkFeatureFactory {
const NoSplashFactory();
@override
InteractiveInkFeature create(
{MaterialInkController controller,
RenderBox referenceBox,
Offset position,
Color color,
TextDirection textDirection,
@slightfoot
slightfoot / sliver_scroll.dart
Last active October 22, 2022 11:54
Example of having a layout with nested scrolling tabs with Slivers.
// MIT License
//
// Copyright (c) 2019 Simon Lightfoot
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@slightfoot
slightfoot / main.dart
Last active June 19, 2022 11:15
Firebase Login/Logout Example - by Simon Lightfoot
/*
This example uses the following packages:
firebase_auth: 0.14.0+5
google_sign_in: 4.0.7
provider: 3.1.0+1
Make sure you have setup your project with Firebase by following these instructions:
1. Follow Option 1 instructions here up to Step 3
@Takhion
Takhion / ExhaustiveWhen.kt
Last active July 28, 2021 19:19
Exhaustive `when` mapping in Kotlin
@file:Suppress("PackageDirectoryMismatch") // root package looks great when importing, ie. `import exhaustive`
/**
* Allows requiring an exhaustive mapping in a `when` block when used with the [rangeTo] operator.
* @sample [exhaustive_when_example]
*/
@Suppress("ClassName") // lowercase because it should look like a keyword
object exhaustive {
@florina-muntenescu
florina-muntenescu / BaseDao.kt
Last active September 28, 2023 15:01
Use Dao inheritance to reduce the amount of boilerplate code - https://medium.com/google-developers/7-pro-tips-for-room-fbadea4bfbd1
/*
* Copyright (C) 2017 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
@simonbasle
simonbasle / collapseAll.js
Last active August 16, 2019 09:13
Collapsing and loading all files in a large pull request, from Chrome Dev Tools
//tested on GitHub 2017-03-24, this collapses all diffs including non-loaded ones
$$('.pr-2').forEach(function(element){if(element.attributes['aria-label'].value == "Toggle diff text") { element.click(); }});
@JakeWharton
JakeWharton / Truss.java
Last active June 9, 2023 07:35
Extremely simple wrapper around SpannableStringBuilder to make the API more logical and less awful. Apache 2 licensed.
import android.text.SpannableStringBuilder;
import java.util.ArrayDeque;
import java.util.Deque;
import static android.text.Spanned.SPAN_INCLUSIVE_EXCLUSIVE;
/** A {@link SpannableStringBuilder} wrapper whose API doesn't make me want to stab my eyes out. */
public class Truss {
private final SpannableStringBuilder builder;
private final Deque<Span> stack;
@swankjesse
swankjesse / RetrofitCachingExample.java
Created June 29, 2013 03:03
Demonstrate HTTP caching with OkHttp and Retrofit.
/*
* Copyright (C) 2013 Square, Inc.
*
* 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