This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#PYTHON FILTER String LIST VIA LAMBDA | |
list = ["Main.py", "util.py", "Test.py", "Main.java", "Util.java", "Test.java"] | |
#GET ALL FILES ENDING WITH .py | |
allpythonfiles = filter(lambda x: x.endswith(".py"), allfiles) | |
#GET ALL FILES ENDING WITH .java | |
allpythonfiles = filter(lambda x: x.endswith(".java"), allfiles) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find . -name "*textToSearch*" -print | |
find . -iname "*textToSearch*" -print (case insensitive) | |
--recursive search for a file in directory that contains 'textToSearch' in file name | |
find . -maxdepth 1 -name "*textToSearch*" -print | |
-- -maxdepth 1 - means search only in current directory, not subdirectories | |
-- https://stackoverflow.com/questions/11328988/find-all-files-with-name-containing-string | |
find libdir -name "*.jar" -exec zipgrep "TEXTTOFINDINSIDEJAR" '{}' \; | |
find . -name "*.jar" -exec zipgrep "TEXTTOFINDINSIDEJAR" '{}' \; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading image with updates | |
- takes more process/memory than regular image loading in flutter | |
- advantage: sure that the image is updated properly | |
1. load image from /data/picture1.jpg (1001 bytes) | |
2. replace image but retain same name /data/picture1.png (850 bytes) | |
* normal loading will not update the image, using the below code the change in image gets reflected | |
ClipRRect( | |
borderRadius: BorderRadius.circular(16.0), | |
child: Image.memory( | |
Uint8List.fromList( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Prints the items in the list with delay | |
*/ | |
StreamSubscription<String> timerSubscription; | |
List<String> iterable = ["2", "1", "x"]; | |
timerSubscription = Observable.fromIterable(timerText).concatMap((i) { | |
return new Observable.timer(i, Duration(seconds: 1)); | |
}).listen((x) { | |
print(x); //Prints "2" , 1 sec later then prints "1", 1 sec later prints "x" | |
if (x == iterable[0]) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context | |
import android.graphics.drawable.Drawable | |
import android.graphics.drawable.ShapeDrawable | |
import android.graphics.drawable.shapes.RectShape | |
import android.support.v4.content.ContextCompat | |
import android.support.v4.widget.NestedScrollView | |
import android.text.method.ScrollingMovementMethod | |
import android.view.Gravity |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//source: https://github.com/ReactiveX/RxJava/issues/3505 | |
####Emit each item 5 seconds after the previous item: | |
List<Integer> list = new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5, 6)); | |
Observable | |
.interval(5, TimeUnit.SECONDS) | |
.map(i -> list.get(i.intValue())) | |
.take(list.size()) | |
.toBlocking() | |
.subscribe(System.out::println) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DialogFragmentClass{ | |
@Override | |
public void onStart() { | |
super.onStart(); | |
int width = (int)(getResources().getDisplayMetrics().widthPixels*0.95); | |
int height = (int)(getResources().getDisplayMetrics().heightPixels*0.30); | |
getDialog().getWindow().setLayout(width, ViewGroup.LayoutParams.WRAP_CONTENT); | |
//THIS WILL MAKE WIDTH 90% OF SCREEN | |
//HEIGHT WILL BE WRAP_CONTENT | |
//getDialog().getWindow().setLayout(width, height); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.view.View; | |
/** | |
* inspired and credits | |
* @see http://stackoverflow.com/questions/16534369/avoid-button-multiple-rapid-clicks | |
* A Debounced OnClickListener | |
* Rejects clicks that are too close together in time. | |
* This class is safe to use as an OnClickListener for multiple views, and will debounce each one separately. | |
* This class allows a single click and prevents multiple clicks on | |
* the same button in rapid succession. Setting unclickable is not enough |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//see https://stackoverflow.com/questions/37067271/android-graphics-drawing-same-size-circles | |
float devicePixelsWidth = fragment.getResources().getDisplayMetrics().widthPixels; | |
float deviceActualDpi = fragment.getResources().getDisplayMetrics().xdpi ; | |
float deviceActualInchWidth = devicePixelsWidth / deviceActualDpi ; | |
float deviceActualCMWidth = deviceActualInchWidth * 2.54f ; | |
float PixelsForActual3CM = devicePixelsWidth / deviceActualCMWidth * 3; | |
float radius = (float) (devicePixelsWidth / deviceActualCMWidth * 0.05); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//----------------------------------SHORTCUTS---------------------- | |
AUTORESIZE LABEL ACCORDING TO TEXT | |
- SELECT LABEL + press CMD + '=' | |
STRING CONCAT | |
//let passwordInput = "HI THERE" | |
//let usernameInput = "HELLO THERE | |
let passwordInput:String = passwordField.text ?? "" | |
let usernameInput:String = userNameField.text ?? "" | |
let age = 19 |
NewerOlder