Skip to content

Instantly share code, notes, and snippets.

@fabriciovergara
fabriciovergara / pubspec_base_sync.py
Created February 17, 2022 15:50
Flutter: Sync pubspec file in melos project with flavors
import sys
import glob
import ruamel.yaml
yaml = ruamel.yaml.YAML()
def main():
# python3 pubspec_base_sync.py ../pubspec_base_android.yaml ../pubspec_base_android_huawei.yaml
@ChristopherME
ChristopherME / recyclerview-fix-leak-extension.kt
Last active March 25, 2023 14:05
This extension method is a solution for a memory leak problem with recyclerviews.
/**
* Set the adapter and call [clearReference] extension function in one call.
* Use this extension if the current Fragment is going to be REPLACED. (When using fragmentTransaction.add is not necessary) the back stack.
*/
fun <VH : RecyclerView.ViewHolder> RecyclerView.setNullableAdapter(
adapter: RecyclerView.Adapter<VH>
) {
this.adapter = adapter
this.clearReference()
@alexjlockwood
alexjlockwood / TypedArrayUtils.kt
Created August 13, 2019 16:51
Kotlin helper functions for extracting ColorStateLists and Drawables from a TypedArray using AppCompatResources.
import android.content.Context
import android.content.res.ColorStateList
import android.content.res.TypedArray
import android.graphics.drawable.Drawable
import androidx.annotation.StyleableRes
import androidx.appcompat.content.res.AppCompatResources
/**
* Utility methods for extracting [ColorStateList]s and [Drawable]s from a [TypedArray].
@webinista
webinista / RunAProxyOnAmazonEC2VPC.md
Last active April 27, 2024 12:21
Create a proxy server on an Amazon EC2 (VPC) instance

This will create a proxy server in whatever your availability zone your VPC is in. For me, that's us-east-1b. For you, that may be something different. Steps 10+ should more or less work regardless of your provider since those steps cover the setup and configuration of TinyProxy.

  1. Click the Launch Instance button.
  2. Choose Ubuntu Server 14.04 LTS (HVM), SSD Volume Type. This isn't strictly necessary. If you choose another OS, check its documentation for how to install new packages.
  3. On the Choose an Instance Type screen, select t2.micro. It's Free Tier eligible.
  4. Click the Next: ... buttons until you reach the Configure Security Group screen.
    • You may wish to reduce the amount of storage on the Add Storage screen. This is optional.
    • You may wish to add a tag on the Tag Instance screen. This is also optional.
  5. On the Configure Security Group screen:
  • Select Create a new security group.