Skip to content

Instantly share code, notes, and snippets.

@ftabashir
ftabashir / ActivityScope.kt
Created May 15, 2020 17:39 — forked from marcellogalhardo/ActivityScope.kt
Scoping Dagger Components with ViewModels
@Scope
@Retention(AnnotationRetention.RUNTIME)
annotation class ActivityScope
#gives you details on the installed version of Docker
docker version
#runs a container from the image (if it has not a copy of the image in its cache, will download it beforehand)
docker container run hello-world
#getting a list of running containers
docker container ls
#getting a list of all containers
docker container ls --all
- Create Security Profiles
- Wireless -> Security Profiles
- Create wireless interface
- Wireless -> Interfaces -> add Virtual AP
- name: wlan2
- SSID: my_custom_ssid
- Master Interface: wlan
- Assign an IP Pool and Address
-  IP -> Address > +
- Address: 10.10.10.1/24
- when to use removeObservers?
- reuse LD in repo or create new instance per repo requet? i prefer to reuse
- use singleton repos?
- use single event? or LiveData.setValue(null)?
- best practice: use Event class (see https://link.medium.com/qjuB2VGnoV)
- use live data or single event in repo?
- if we don't reuse LD in repo, then we could use LD (single event is useless)
- observeForever is not implemented in single live event
- mediators internally use observeForever
- Use a repo livedata in two view models:
@ftabashir
ftabashir / safe-object.ts
Last active October 31, 2018 12:02
safe Object property access, using ES6's Proxy and also make it typed!
/*
Using ES6's Proxy for safe Object property access
This gist is inspired from:
https://gidi.io/2016/02/07/using-es6-s-proxy-for-safe-object-property-access.html
*/
const isObject = (obj: any) => obj && typeof obj === "object";
const hasKey = (obj: any, key: string | number | symbol) => key in obj;
const UndefinedObj: ProxyHandler<{}> = new Proxy(
docker pull node:8.12-alpine
docker image ls
docker image rm
docker run --name <container-name> node:8.12-alpine
docker ps -a
docker rm <container-name>
docker run -it --name dnode node:8.12-alpine sh
docker start dnode
docker stop dnode
docker restart dnode
@ftabashir
ftabashir / play_mp3.py
Created January 20, 2018 21:08
python - play random mp3 using windows media player
# example of running this file: python play_mp3.py path/to/root/mp3/directory 45
# 45 in above example is number of files to play (optional)
import os,random,time,sys,subprocess,threading
def getFiles(path, extension, recursive=True):
files = []
directories = []
for path,directory,element in os.walk(path,False):
if recursive:
@ftabashir
ftabashir / versionName.cmd
Created December 18, 2017 05:32
a batch file to get versionName of apk (in windows)
aapt.exe dump badging %1 | findstr versionName
pause
@ftabashir
ftabashir / sub.py
Last active December 13, 2017 06:13
ModifyFarsiEnglishSubtitleDirection: when we type rtl and ltr text in the same file in envirements which doesn't support rtl, it scrambles text. this python script tries to fix it.
import sys
def subModify(subtitleStr):
modified = []
words = subtitleStr.split()
insertIndex = -1
curIsEn = False
preIsEn = False
for word in words:
preIsEn = curIsEn
package com.iranfmcg.dokan.customer.helper;
import android.os.AsyncTask;
import android.support.annotation.MainThread;
import android.support.annotation.WorkerThread;
/* Copyright (C) Farzad Tabashir <ftabashir@gmail.com> 15 February 2017, 8:38 AM
* All Rights Reserved
*/
public abstract class SafeAsyncTask<Params, Progress, Result> {