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
https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts | |
https://mirror1.malwaredomains.com/files/justdomains | |
http://sysctl.org/cameleon/hosts | |
https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt | |
https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt | |
https://hosts-file.net/ad_servers.txt | |
https://raw.githubusercontent.com/MajkiIT/polish-ads-filter/master/polish-pihole-filters/hostfile.txt | |
https://raw.githubusercontent.com/MajkiIT/polish-ads-filter/master/polish-pihole-filters/easylist_host.txt | |
https://raw.githubusercontent.com/MajkiIT/polish-ads-filter/master/polish-pihole-filters/easy_privacy_host.txt | |
https://raw.githubusercontent.com/MajkiIT/polish-ads-filter/master/polish-pihole-filters/gambling-hosts.txt |
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
fun jaccardSimilarity(first: Array<Int>, second: Array<Int>): Float { | |
val s1 = first.toSet() | |
val s2 = second.toSet() | |
return s1.intersect(s2).size / s1.union(s2).size.toFloat() | |
} | |
class Encoder { | |
var base = 0 | |
fun encode(categories: Set<String>) = |
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
val benchmarkList = List<ProducerConsumerCoroutinesOnlyBenchmark>(100) { ProducerConsumerCoroutinesOnlyBenchmark() } | |
launch { | |
val resultList = benchmarkList.map { | |
it.startBenchmark() | |
} | |
val resultReduced = resultList.reduce {sum, element -> | |
ProducerConsumerCoroutinesOnlyBenchmark.Result(sum.executionTime + element.executionTime, sum.numOfReceivedMessages + element.numOfReceivedMessages) | |
} | |
Log.d("FragmentCoroutinesDemo", "Result not reduced " + resultReduced.executionTime + "ms") |
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.techyourchance.multithreading.demonstrations.purecoroutines | |
import android.util.Log | |
import com.techyourchance.multithreading.DefaultConfiguration | |
import kotlinx.coroutines.* | |
import kotlinx.coroutines.channels.Channel | |
import java.util.concurrent.atomic.AtomicInteger | |
class ProducerConsumerCoroutinesOnlyBenchmark { |
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
fun Array<Int>.quickSort() { | |
quickSortImpl(this, 0, this.lastIndex) | |
} | |
fun quickSortImpl(input: Array<Int>, leftIndex: Int, rightIndex: Int) { | |
if (input.size <= 1) return | |
val pivotIndex = (leftIndex + rightIndex) / 2 | |
val pivotValue = input[pivotIndex] | |
input[pivotIndex] = input[rightIndex] | |
var j = leftIndex |
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
class SampleService : Service() { | |
companion object { | |
private val LAUNCHER = ForegroundServiceLauncher(SampleService::class.java) | |
@JvmStatic | |
fun start(context: Context) = LAUNCHER.startService(context) | |
@JvmStatic | |
fun stop(context: Context) = LAUNCHER.stopService(context) | |
} |
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
class ForegroundServiceLauncher(private val serviceClass: Class<out Service>) { | |
private var isStarting = false | |
private var shouldStop = false | |
@Synchronized | |
fun startService(context: Context, block: Intent.() -> Unit = {}) { | |
isStarting = true | |
shouldStop = false | |
ContextCompat.startForegroundService(context, Intent(context, serviceClass).apply { block() }) |
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 android.arch.lifecycle.GenericLifecycleObserver | |
import android.arch.lifecycle.Lifecycle | |
import android.arch.lifecycle.Lifecycle.Event.ON_DESTROY | |
import android.arch.lifecycle.LifecycleOwner | |
import kotlinx.coroutines.experimental.CoroutineScope | |
import kotlinx.coroutines.experimental.Dispatchers | |
import kotlinx.coroutines.experimental.Job | |
import kotlinx.coroutines.experimental.android.Main | |
fun Lifecycle.createJob(cancelEvent: Lifecycle.Event = ON_DESTROY): Job { |
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 requests | |
import sys | |
from bs4 import BeautifulSoup | |
URL_AMW = "https://amw.com.pl/pl/uzbrojenie-i-sprzet-wojskowy/sprzet-wojskowy/sprzedaz-bezprzetargowa/wyniki" \ | |
"-wyszukiwania" | |
params = {"search": sys.argv[1]} | |
response = requests.get(URL_AMW, params=params) |
NewerOlder