Skip to content

Instantly share code, notes, and snippets.

View patrickcousins's full-sized avatar

Patrick Cousins patrickcousins

View GitHub Profile
@jrgutier
jrgutier / rivian_software_update_notification.yaml
Created March 15, 2023 02:03
Rivian Software Update Notification
alias: Rivian Software Update Notification
description: ""
trigger:
- platform: state
entity_id:
- sensor.rivian_telematics_ota_status_status
condition:
- condition: template
value_template: |-
{{ trigger.to_state.state != trigger.from_state.state and
abrp_request:
url: >
{% set token = "REPLACE_ME_WTH_ABRP_TOKEN" %}
{% set params = [] %}
{% set params = params + ['"utc":' ~ now().timestamp()] %}
{% set params = params + ['"soc":' ~ states('sensor.r1t_battery_state_of_charge')] %}
{% set params = params + ['"lat":' ~ state_attr('device_tracker.r1t_location', 'latitude')] %}
{% set params = params + ['"lon":' ~ state_attr('device_tracker.r1t_location', 'longitude')] %}
{% set params = params + ['"heading":' ~ states('sensor.r1t_bearing')] %}
{% set params = params + ['"speed":' ~ (0 if is_state('sensor.r1t_gear_selector', 'Park') else states('sensor.r1t_speed') | float * 1.609344)] %}

Memory Leaks

Setup Leak Canary

Context Leaks via Threads

  • When not static will retain reference to outer class beyond lifecycle of container (Activity, Fragment). In below example MyTask will retain a reference to Activity
@tatianamac
tatianamac / tatiana-mac-speaker-rider.md
Last active March 24, 2024 12:22
Tatiana Mac's Speaker Rider

Speaker Rider

by Tatiana Mac

Last updated 14 April 2021

What is a speaker rider?

As speaking comes with immense privilege, I have crafted a speaker rider to set expectations and boundaries around my engagement. I am grateful to all the conference organisers who have brilliantly hosted me. I would love to continue to exercise this privilege to speak at conferences, and use this privilege to make the landscape more accessible and beneficial to tech's most historically excluded and marginalised communities.

Considerations

😫 I provide a lot of explanations for those of you who never had to consider these things. Most thoughtful conferences I've attended check most of these boxes intrinsically, particularly when conference runners are experienced speakers. They get it.

^(?!.*(BtGatt|dalvik|Environment|DataRouter|FA|art|Wifi|ServiceManager|Atfwd|tnet|MDnsDS|Download|Bluetooth|slim|QSEECOMAPI|WVCdm|QC-time|sensors|nanohub|Drm|Babel|Dropbox|gsamlab|Cryptd|Vold|QC_|Conscrypt|Dns|sound|NetWork|OpenGL|TLog|GMPM|Microphone|Process|Dynamite|cr_|VideoCapabilities|libEGL|NetdEventListenerService|Sensors|Netd|audit|Zygote|Watchdog|ity|memtrack|fb4a|LoadedApk|ImsAdaptorImpl|EPDG|CursorWindow|tworkdiagnosti|PackageManager))
@andymatuschak
andymatuschak / States-v3.md
Last active May 1, 2024 12:32
A composable pattern for pure state machines with effects (draft v3)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

@rock3r
rock3r / README.md
Last active January 27, 2024 14:51
A simple bash script to enable demo mode on a Marshmallow+ device via ADB (based on http://bit.ly/295BHLx)

Usage

$ demo on|off [hhmm]

Enable or disable the demo mode on a connected Android device or emulator. You can also pass in a custom value for the system clock in the HHMM format (only used when you use the on command).

⚠️ This script only works on *nix systems and has only been tested on macOS with Bash (but should be portable).

@dlew
dlew / File.java
Created March 1, 2016 20:46
Automated onError() message generation
public static Action1<Throwable> crashOnError() {
final Throwable checkpoint = new Throwable();
return throwable -> {
StackTraceElement[] stackTrace = checkpoint.getStackTrace();
StackTraceElement element = stackTrace[1]; // First element after `crashOnError()`
String msg = String.format("onError() crash from subscribe() in %s.%s(%s:%s)",
element.getClassName(),
element.getMethodName(),
element.getFileName(),
element.getLineNumber());
@JakeWharton
JakeWharton / GenericCovariants.java
Created January 7, 2016 06:32
Unlike synthetic accessor methods, these synthetic covariant methods are hard or impossible to kill. Generics anyone?
interface Thing<T> {
T thing();
}
class CharSequenceThing implements Thing<CharSequence> {
@Override public CharSequence thing() {
return "CharSequence!";
}
}