This file contains hidden or 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 f1() { | |
// Anonymous function: this will print 1 2, return acts like a break. | |
listOf(1,2).forEach(fun(it: Int): Unit { | |
println(it) | |
return | |
}) | |
} | |
This file contains hidden or 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.net.Uri | |
import com.commonsound.common.data.flickr.FlickrApi.Routes.FLICKR_REST_SERVICE | |
import com.commonsound.common.data.flickr.models.FlickrPhotoModel | |
import io.ktor.client.* | |
import kotlinx.coroutines.Dispatchers | |
import kotlinx.coroutines.withContext | |
import org.w3c.dom.NodeList | |
import java.io.BufferedInputStream | |
import java.io.BufferedReader | |
import java.net.URL |
This file contains hidden or 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 XCTest | |
import CoreData | |
@testable import iosApp | |
class iosAppTests: XCTestCase { | |
func testCoreDataMergeConflict() { | |
let expectation = XCTestExpectation(description: "") | |
expectation.expectedFulfillmentCount = 2 | |
This file contains hidden or 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 Foundation | |
import CoreData | |
final class CoreDataInventory { | |
static let instance = CoreDataInventory() | |
let persistentContainer: NSPersistentContainer | |
let viewContext: NSManagedObjectContext | |
private let backgroundContext: NSManagedObjectContext | |
This file contains hidden or 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 XCTest | |
import CoreData | |
@testable import iosApp | |
class iosAppTests: XCTestCase { | |
/* | |
ChartState - is a CoreData entity with two fields: chartLen and seed: | |
<entity name="ChartState" representedClassName="ChartState" syncable="YES" codeGenerationType="class"> |
This file contains hidden or 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
use std::collections::HashMap; | |
fn bestSum(targetSum: i32, v: &Vec<i32>, memo: &mut HashMap<i32, Vec<i32>>) -> Vec<i32> { | |
if targetSum == 0 { return vec![]; } | |
if targetSum < 0 { return vec![-1]; } | |
if memo.contains_key(&targetSum) { | |
return memo[&targetSum].clone(); | |
} | |
let mut result: Vec<i32> = Vec::new(); |
This file contains hidden or 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.example.myapplication | |
import io.reactivex.Observable | |
import okhttp3.mockwebserver.MockWebServer | |
import org.junit.Rule | |
import org.junit.Test | |
import retrofit2.Retrofit | |
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory | |
import retrofit2.converter.gson.GsonConverterFactory | |
import retrofit2.http.* |
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<ScrollView | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:fillViewport="true"> | |
<FrameLayout android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_margin="20dp"> |
This file contains hidden or 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
let list = []; | |
let nums = [1,2,3]; | |
function backtrack(nums, temparray, startindex) { | |
list.push(temparray.slice()); | |
for (var i = startindex; i < nums.length; i++) { | |
temparray.push(nums[i]); | |
backtrack(nums, temparray, i + 1); | |
temparray.pop(); |
This file contains hidden or 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 javaapplication1; | |
/** | |
* Test java ThreadPoolExecutor can shrink to guarantee only one thread is executing at a given | |
* time, and then restore thread pool size. | |
*/ | |
import java.util.concurrent.BlockingQueue; | |
import java.util.concurrent.CountDownLatch; | |
import java.util.concurrent.LinkedBlockingQueue; |