Skip to content

Instantly share code, notes, and snippets.

View markus2610's full-sized avatar

Markus markus2610

View GitHub Profile
@markus2610
markus2610 / maven-publish-helper-usage.gradle
Created April 17, 2020 10:27 — forked from Robyer/maven-publish-helper-usage.gradle
Gradle script for publishing Android library with sources and javadoc to Maven repository using maven-publish plugin.
// You can use maven-publish-helper.gradle script without changes and even share it between multiple
// modules. Just place the maven-publish-helper.gradle file in the root directory of your project,
// then apply it at the bottom of your module's build.gradle file like this:
// ...content of module's build.gradle file...
apply from: '../maven-publish-helper.gradle'
publishing {
publications {
public void readTwice()
{
Observable.fromCallable(() -> {
RedditData inflatedModel = null;
Response response = makeRequest();
String diskValue = null;
try {
File file = new File(getContext().getCacheDir(), "file");
BufferedSink cacheBody = Okio.buffer(Okio.sink(file));
@markus2610
markus2610 / DownloadRequest.kt
Created September 6, 2019 15:59 — forked from PrashamTrivedi/DownloadRequest.kt
Download File with progress indicator, written in Kotlin with Co-routines
suspend fun downloadFile(url: String,
downloadFile: File,
downloadProgressFun: (bytesRead: Long, contentLength: Long, isDone: Boolean) -> Unit) {
async(CommonPool) {
val request = with(Request.Builder()) {
url(url)
}.build()
val client = with(OkHttpClient.Builder()) {
addNetworkInterceptor { chain ->
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
void learnTypesAndSize() {
/** TYPES */
cout << "\n:::: TYPES ::::" << endl;
@markus2610
markus2610 / cpp17.md
Created April 23, 2019 09:34 — forked from RedBeard0531/cpp17.md
New C++17 features

Supplement to this video. Watch first 35 min (the language bits), then 1:14:30 - 1:18:15 (the new map features).

You can find a fairly comprehensive list of new features on cppreference or here if you really want to see it all.

Recap of features described in the video

C++ Coding Standards Part 0: Automated Code Analysis

Automated analysis is the main advantage to working with a modern statically typed compiled language like C++. Code analysis tools can inform us when we have implemented an operator overload with a non-canonical form, when we should have made a method const, or when the scope of a variable can be reduced.

In short, these tools catch the most commonly agreed best practice mistakes we are making and help educate us to write better code. We will be fully utilizing these tools.

Compilers

All reasonable warning levels should be enabled. Some warning levels, such as GCC's -Weffc++ warning mode can be too noisy and will not be recommended for normal compilation.

@markus2610
markus2610 / CoroutineChannels.kt
Created March 21, 2019 12:32 — forked from CodyEngel/CoroutineChannels.kt
This is an example of the different channel types with coroutines and some scenarios. Note that sendBlockingBeforeReceiverScenario will cause the program to stop executing, DON'T USE SENDBLOCKING!
import kotlinx.coroutines.experimental.GlobalScope
import kotlinx.coroutines.experimental.channels.Channel
import kotlinx.coroutines.experimental.channels.Channel.Factory.CONFLATED
import kotlinx.coroutines.experimental.channels.Channel.Factory.UNLIMITED
import kotlinx.coroutines.experimental.channels.sendBlocking
import kotlinx.coroutines.experimental.launch
fun main(args: Array<String>) {
val channels = listOf<Channel<Int>>(
Channel(capacity = UNLIMITED),
@markus2610
markus2610 / ChatRoomsFragment.kt
Created March 20, 2019 13:40 — forked from luciofm/ChatRoomsFragment.kt
How to run LiveData transformations on a coroutine
class ChatRoomsFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
viewModel = ViewModelProviders.of(this, factory).get(ChatRoomsViewModel::class.java)
subscribeUi()
}
private fun subscribeUi() {
@markus2610
markus2610 / index.md
Created October 3, 2018 16:54 — forked from ericandrewlewis/index.md
C++ Pointer Tutorial

C++ Pointer Tutorial

Because pointers can be ugh

"Regular" variables (not pointers)

To understand a pointer, let's review "regular" variables first. If you're familiar with a programming language without pointers like JavaScript, this is what you think when you hear "variable".

When declaring a variable by identifier (or name), the variable is synonymous with its value.

@markus2610
markus2610 / Example.java
Created August 29, 2018 17:19 — forked from RyanRamchandar/Example.java
Cancel a running or queued Call with OkHttp3
// ...
Request request = new Request.Builder()
.url(url)
.tag(TAG)
.build();
// Cancel previous call(s) if they are running or queued
OkHttpUtils.cancelCallWithTag(client, TAG);
// New call