Skip to content

Instantly share code, notes, and snippets.

View apgapg's full-sized avatar
😉
Still not born...

Ayush P Gupta apgapg

😉
Still not born...
View GitHub Profile
@apgapg
apgapg / delete-old-remote-branches.sh
Created April 17, 2024 06:00
Delete old Git branches from remote
#!/bin/bash
# Set the cutoff date 6 months ago
cutoff_date=$(date -d "6 months ago" +%Y-%m-%d)
# Fetch all branches from the remote repository
git fetch --prune
# Iterate over each remote branch
for branch_with_origin in $(git branch -r --format='%(refname:short)'); do
@apgapg
apgapg / submodules.sh
Created December 19, 2023 16:22
Replace url with PAT in github root and nested submodules
#!/bin/bash
# Root project having .gitmodules
PROJECT[0]="."
# Another project inside root project having .gitmodules
PROJECT[1]="project1"
for i in "${PROJECT[@]}"
do
cd $i
@apgapg
apgapg / pie_chart.dart
Created March 29, 2022 17:48
Pie Chart with base color support
class HomePage2 extends StatelessWidget {
HomePage2({Key? key}) : super(key: key);
final dataMap = <String, double>{
"Flutter": 5,
};
final colorList = <Color>[
Colors.greenAccent,
];
@apgapg
apgapg / azure.azcli
Last active March 2, 2022 03:25
VS code Script that purges old acr images and retains latest 5
# This vs code script purges the old images in 'acr' (Azure Container Registry) via 'az' cli.
# Retains only latest 5 in a particular repository
# You need to change 'myacr' with your acr name and 'mysubs' with your subscription name.
# Make sure az cli is installed and logged in.
#
# Read more: https://docs.microsoft.com/en-us/azure/container-registry/container-registry-auto-purge
# azcli: https://github.com/Microsoft/vscode-azurecli
# List subscriptions
az account list --output table
@apgapg
apgapg / flutter_linux_arch.shell
Created January 6, 2022 03:44
Flutter linux desktop commands for Arch based linux
sudo pacman -S clang cmake ninja pkgconf gtk3
name: Azure Static Web Apps CI/CD
on:
push:
branches:
- dev/docker
jobs:
build:
@apgapg
apgapg / contributors.yml
Created April 27, 2021 03:47
Add auto contributors to README workflow
name: Add contributors
on:
schedule:
- cron: '0 0 * * 0'
jobs:
add-contributors:
name: Add contributors to README.md
runs-on: ubuntu-latest
steps:
@apgapg
apgapg / error_interceptor.dart
Created April 9, 2021 07:27
Handling error
abstract class ErrorInterceptor extends Interceptor {
@override
Future onError(DioError err) async {
if (err is NoInternetError) {
return NoInternetError();
} else if (err.type == DioErrorType.response) {
final code = err.response!.statusCode;
if (code == 401) {
await onUnauthorizedError();
return UnauthorizedError();
@apgapg
apgapg / git-log.bash
Last active April 1, 2021 03:53
Get commits since last tag in pretty format
# Make sure you run this in valid git repository
git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:'@begin@%s@space@%B@end@' > new-in-this-release.log
# You can use following formats below to modify your --pretty output
# {
# hash: "%H",
# abbrevHash: "%h",
# treeHash: "%T",
# abbrevTreeHash: "%t",
@apgapg
apgapg / property_value_notifier.dart
Created October 12, 2020 09:40
Call notifyListeners which otherwise is protected in ValueNotifier
import 'package:flutter/material.dart';
class PropertyValueNotifier<T> extends ValueNotifier<T> {
PropertyValueNotifier(T value) : super(value);
@override
void notifyListeners() {
super.notifyListeners();
}
}