Skip to content

Instantly share code, notes, and snippets.

@abhaysood
abhaysood / scripts
Created May 16, 2017 11:36
Useful Scripts
// Add a PREFIX to all file names in a directory
ls | xargs -I {} mv {} PREFIX_{}
@abhaysood
abhaysood / order_cancelation_component.kt
Last active March 18, 2018 20:02
A simple component which is created when user clicks the cancel order button in the app. It is responsible for showing a confirmation dialog and actually cancelling the order by making an API call.
class OrderCancellationComponent(private val context: Context,
private val api: Api,
private val orderNumber: String) {
interface Callbacks {
fun onOrderCancelledSuccessfully()
fun onOrderCancellationFailed()
}
var callbacks: Callbacks? = null // Callbacks for communication with the parent component
@abhaysood
abhaysood / SketchSystems.spec
Created September 30, 2018 17:58
Home Screen*
Home Screen*
Empty
query changed -> Searching
Showing Results
query changed -> Searching
Searching
network error -> Network Error
server error -> Server Error
class RootComponent(...) {
val locationSelection = LocationSelectionComponent(...)
fun launchLocationSelection() {
// Create the component
locationSelection = LocationSelectionComponent(...)
// Register callbacks
locationSelection.callbacks = object: LocationSelectionComponent.Callbacks() {
@abhaysood
abhaysood / OnMapAndLayoutReady.java
Created April 15, 2017 08:04
GoogleMaps onReadyCallback + GlobalLayoutListener to avoid `Map size should not be 0`
import android.util.Log;
import android.view.ViewTreeObserver;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.OnMapReadyCallback;
import rx.Observable;
import rx.Subscriber;
import rx.functions.Func2;
@abhaysood
abhaysood / medium_rider_redesign_blog_example.kt
Created March 18, 2018 20:04
A simple component which is created when user clicks the cancel order button in the app. It is responsible for showing a confirmation dialog and actually cancelling the order by making an API call.
class OrderCancellationComponent(private val context: Context,
private val api: Api,
private val orderNumber: String) {
interface Callbacks {
fun onOrderCancelledSuccessfully()
fun onOrderCancellationFailed()
}
var callbacks: Callbacks? = null // Callbacks for communication with the parent component
@abhaysood
abhaysood / machine.js
Last active September 26, 2020 05:41
Generated by XState Viz: https://xstate.js.org/viz
const summaryState = {
type: 'parallel',
initial: 'loadOrder',
states: {
loadOrder: {
initial: 'loadingOrder',
states: {
idle: {},
loadingOrder: {
on: {
@abhaysood
abhaysood / main.dart
Created April 27, 2021 07:21
Drag and drop to delete from list
import 'package:flutter/material.dart';
import 'dart:math';
import 'dart:ui' show lerpDouble;
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
@abhaysood
abhaysood / Dockerfile
Created May 17, 2021 07:18
Dockerfile to build flutter apps/packages: comes with alpine, FVM, Android SDK, flutter stable, lcov
FROM openjdk:8-alpine
USER root
ARG FVM_VERSION="2.0.4"
# Required to build flutter apps on apline
ARG GLIBC_VERSION="2.28-r0"
ENV LCOV_VERSION="1.15"
@abhaysood
abhaysood / pre-commit
Created May 18, 2021 19:05
A pre-commit hook which fails a commit if formatting issues are encountered (Flutter)
#!/bin/bash
red=`tput setaf 1`
green=`tput setaf 2`
reset=`tput sgr0`
fileList=$(git diff --diff-filter=d --cached --name-only | grep -E '\.(dart)$')
if [ ${#fileList} -lt 1 ]; then
# No changes to dart files continue with git commit.
exit
fi