This file contains 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
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:id="@+id/drawer_layout" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:elevation="7dp"> | |
<android.support.v7.widget.Toolbar | |
android:id="@+id/toolbar" | |
android:layout_width="match_parent" | |
android:layout_height="?attr/actionBarSize" |
This file contains 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
private static ArrayList<View> getViewsByTag(ViewGroup root, String tag){ | |
ArrayList<View> views = new ArrayList<View>(); | |
final int childCount = root.getChildCount(); | |
for (int i = 0; i < childCount; i++) { | |
final View child = root.getChildAt(i); | |
if (child instanceof ViewGroup) { | |
views.addAll(getViewsByTag((ViewGroup) child, tag)); | |
} | |
final Object tagObj = child.getTag(); |
This file contains 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
public static void logsOf(String veryLongString, int maxLogSize) { | |
for (int i = 0; i <= veryLongString.length() / maxLogSize; i++) { | |
int start = i * maxLogSize; | |
int end = (i + 1) * maxLogSize; | |
end = end > veryLongString.length() ? veryLongString.length() : end; | |
Log.v(TAG, veryLongString.substring(start, end)); | |
} | |
} |
This file contains 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 org.graphstream.graph.Edge; | |
import org.graphstream.graph.Element; | |
import org.graphstream.graph.Graph; | |
import org.graphstream.graph.Node; | |
import org.graphstream.graph.implementations.SingleGraph; | |
import util.Log; | |
import java.util.Iterator; |
This file contains 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
String[] getIds = new String[]{"id:0", "id:1", "id:2", "id:3"}; | |
rx.Observable.just(getIds) | |
.flatMap(new Func1<String[], Observable<String>>() { | |
@Override | |
public Observable<String> call(String[] strings) { | |
//dla kazdego id odpytaj api | |
return Observable.from(strings); | |
} | |
}).flatMap(new Func1<String, Observable<Integer>>() { | |
@Override |
This file contains 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
public static void main(String[] argv) { | |
new CesarCipher().solve(); | |
} | |
public void solve() { | |
Scanner in = new Scanner(System.in); | |
int t = Integer.valueOf(in.nextLine()); | |
String line = in.nextLine(); | |
StringBuilder sb = new StringBuilder(); | |
String keys = in.nextLine(); |
This file contains 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
int threadCt = Runtime.getRuntime().availableProcessors() + 1; | |
ExecutorService executor = Executors.newFixedThreadPool(threadCt); | |
Schedulers scheduler = Schedulers.from(executor); | |
Observable.range(1,1000) | |
.groupBy(i -> batch.getAndIncrement() % threadCt ) | |
.flatMap(g -> g.observeOn(scheduler) | |
.map(i -> intenseCalculation(i)) |
This file contains 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
/** | |
* @author Lukasz Marczak | |
* @since 28.09.16. | |
*/ | |
import android.graphics.Bitmap; | |
import android.graphics.BitmapFactory; | |
import android.os.Bundle; | |
import android.support.v7.app.AppCompatActivity; | |
import android.util.Log; | |
import android.view.View; |
This file contains 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
rx.Observable.range(1, 100).map(i -> String.valueOf(i).concat( | |
(i % 15 == 0 ? "FizzBuzz" : i % 3 == 0 ? "Fizz" : i % 5 == 0 ? "Buzz" : ""))) | |
.subscribe(System.out::println); | |
OR, more readable: | |
rx.Observable.range(1, 100).map(i -> i + suffixFor(i)).subscribe(System.out::println); | |
... |
This file contains 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
package com.emil.android.util; | |
import android.content.Context; | |
import android.net.ConnectivityManager; | |
import android.net.NetworkInfo; | |
import android.telephony.TelephonyManager; | |
/** | |
* Check device's network connectivity and speed | |
* @author emil http://stackoverflow.com/users/220710/emil |