Skip to content

Instantly share code, notes, and snippets.

View mrahimygk's full-sized avatar
🎯
Focusing

Mojtaba Rahimy mrahimygk

🎯
Focusing
View GitHub Profile
@mrahimygk
mrahimygk / system_info.c
Last active January 31, 2017 11:08 — forked from mortymacs/system_info.c
Showing system info
#include <stdio.h>
#include <stdlib.h>
#include <sys/utsname.h>
int main(int argc, char *argv[]) {
struct utsname *_system_ = malloc(sizeof(struct utsname));
uname(_system_);
if(argc==2 &&
(strcmp(argv[1], "version")==0
|| strcmp(argv[1],"VERSION" ) == 0))
@mrahimygk
mrahimygk / MergerLiveData.kt
Created July 18, 2019 07:06 — forked from guness/CombinedLiveData.java
LiveData merger that takes two live data inputs and a merger function. Merges two results using merger function, and returning result allowing null inputs and outputs. Input and out types are parametric. However only supports two live data inputs for now.
class CombinedLiveData<T, K, S>(source1: LiveData<T>, source2: LiveData<K>, private val combine: (data1: T?, data2: K?) -> S) : MediatorLiveData<S>() {
private var data1: T? = null
private var data2: K? = null
init {
super.addSource(source1) {
data1 = it
value = combine(data1, data2)
}