Skip to content

Instantly share code, notes, and snippets.

View shakthizen's full-sized avatar
🏠
Working from home

Shakthi Senavirathna shakthizen

🏠
Working from home
View GitHub Profile
@shakthizen
shakthizen / docker_desktop_tcp.md
Last active February 20, 2024 08:45
Enable TCP port in Docker Desktop on ubuntu
  1. Add these lines to the config. You can find the setting in Settings->Docker Engine
  "hosts": [
    "unix:///var/run/docker.sock",
    "tcp://0.0.0.0:2375"
  ]

image

  1. Run below command
@shakthizen
shakthizen / dio_exception.md
Last active October 30, 2024 06:19
Unable to catch Flutter Dio exception

I found a hacky solution. We are overriding all the exceptions thrown by default. Then we are going to create custom interceptor to handle and throw exceptions. This way we can catch the DioException as we did before.

  1. Create a base client like this. You have to set validateStatus function to return true whatever the status code is.
final baseOptions = BaseOptions(
  baseUrl: host,
  contentType: Headers.jsonContentType,
  validateStatus: (int? status) {
    return status != null;
    // return status != null && status >= 200 && status < 300;
@shakthizen
shakthizen / git-gcm.txt
Last active July 14, 2023 07:33
Setup git credential manager on ubuntu
Download and install `.deb` from https://github.com/git-ecosystem/git-credential-manager/releases/latest
Follow instructions from https://github.com/git-ecosystem/git-credential-manager/blob/release/docs/install.md#debian-package
Then do these
```sh
git config --global credential.credentialStore cache
```
@shakthizen
shakthizen / animateToLocation.md
Last active September 27, 2022 11:44
Flutter Maps Animate to location

Refer https://github.com/fleaflet/flutter_map/blob/master/example/lib/pages/animated_map_controller.dart

void _animatedMapMove(LatLng destLocation, double destZoom) {
    // Create some tweens. These serve to split up the transition from one location to another.
    // In our case, we want to split the transition be<tween> our current map center and the destination.
    final latTween = Tween<double>(
        begin: mapController.center.latitude, end: destLocation.latitude);
    final lngTween = Tween<double>(
        begin: mapController.center.longitude, end: destLocation.longitude);
@shakthizen
shakthizen / dart_cast.md
Created July 31, 2022 22:13
Fix flutter dart : type 'List<dynamic>' is not a subtype of type 'List<String>'
List<String> likes;

LiveChat.fromMap(Map<String, dynamic> data) {
  likes = data['likes'].cast<String>();
}

// casts List<dynamic> to List<String>
@shakthizen
shakthizen / pipewire.md
Last active July 9, 2024 14:53 — forked from the-spyke/pipewire.md
Enable PipeWire on Ubuntu 22.04

Enable PipeWire on Ubuntu 22.04

This guide is only for original Ubuntu out-of-the-box packages. If you have added a custom PPA like pipewire-debian, you might get into conflicts.

Ubuntu 22.04 has PipeWire partially installed and enabled as it's used by browsers (WebRTC) for recoding the screeen under Wayland. We can enable remaining parts and use PipeWire for audio and Bluetooth instead of PulseAudio.

Starting from WirePlumber version 0.4.8 automatic Bluetooth profile switching (e.g. switching from A2DP to HSP/HFP when an application needs microphone access) is supported. Jammy (22.04) repos provide exactly version 0.4.8. So, we're good.

Based on Debian Wiki, but simplified for Ubuntu 22.04.