Skip to content

Instantly share code, notes, and snippets.

Index: iosEntryPoint/build.gradle.kts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/iosEntryPoint/build.gradle.kts b/iosEntryPoint/build.gradle.kts
new file mode 100644
--- /dev/null (date 1684762578130)
+++ b/iosEntryPoint/build.gradle.kts (date 1684762578130)
@@ -0,0 +1,40 @@
suspend fun <T> Deferred<Response<T>>.handleResponse(): Deferred<Response<T>> {
val it = await()
throw HttpCodeException(500)
return this
}
suspend fun <T> Deferred<T>.awaitHandlingError(
success: (T) -> Unit, error: (t: Throwable) -> Unit) {
try {
success(this.await())
class ThreadPool:
def __init(self, max_size = 2, task_complete_observer): #task_complete_observer - объект-слушатель прогресса выполнения
self.maxSize = max_size
self.queue = Queue()
self.threads = []
self.task_complete_observer = task_complete_observer
def post_task(task):
if self.has_available_thread():
self.get_available_thread().execute(task)
layout title author
post
j.u.c ExecutorService gotcha

java.util.concurrent ExecutorService allows for a simple way of using a thread pool within a java application. I have seen the following happens in more than one place (including some quite known open source projects) that I thought it make sense to blog about it.

One of the most common scenarios of using a thread pool is creating an unbounded thread pool with minimum and maximum number of threads. With the executor service, you can create the following quite simply:

@eymar
eymar / shadow.xml
Created February 16, 2018 19:46 — forked from lecho/shadow.xml
Android shadow drawable xml.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Drop Shadow Stack -->
<item>
<shape>
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
curl -X GET 'http://shafa-staging.evo/protobuf?query={YOUR QUERY}' -o response.txt
protoc --decode [package.ProtoMessageName] path/response.proto < response.txt >> output.txt
object VectorDrawableFixinator {
private val regexMap = mapOf("\n" to " ",
"(-)(\\.\\d)" to " -0$2",
" (\\.\\d)" to " 0$1",
"([a-z])(\\.\\d)" to "$1 0$2")
fun getContentWithFixedFloatingPoints(value: String): String {
var result = value as CharSequence
val prepareRegex = "(\\.\\d+)(\\.\\d)".toRegex()
@eymar
eymar / links.txt
Last active December 2, 2016 15:14
Links ML & Data Science
@eymar
eymar / BaseRecyclerArrayAdapter.java
Created March 15, 2016 15:13
Base Array Adapter for Recycler Views
public abstract class BaseRecyclerArrayAdapter<T> extends RecyclerView.Adapter<BaseRecyclerArrayAdapter.ViewHolder<T>> {
private List<T> dataSet;
private Context context;
public BaseRecyclerArrayAdapter(List<T> dataSet, Context context) {
super();
this.dataSet = new ArrayList<>(dataSet);
this.context = context;
}
@eymar
eymar / EndlessRecyclerViewScrollListener.java
Created March 15, 2016 15:12
Endless Scroll Listener for Recycler View
public abstract class EndlessRecyclerViewScrollListener extends RecyclerView.OnScrollListener {
// The minimum amount of items to have below your current scroll position
// before loading more.
private int visibleThreshold = 5;
// The current offset index of data you have loaded
private int currentPage = 0;
// The total number of items in the dataset after the last load
private int previousTotalItemCount = 0;
// True if we are still waiting for the last set of data to load.
private boolean loading = true;