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
export async function runForAtLeast<T>(fn: (...args: any[]) => Promise<T>, ms?: number, ...args: any[]): Promise<T> { | |
const [res] = await Promise.allSettled([ | |
fn(...args), | |
new Promise(resolve => setTimeout(resolve, ms)), | |
]); | |
switch (res.status) { | |
case 'fulfilled': | |
return res.value; | |
case 'rejected': | |
throw res.reason; |
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
function generatePaginationQuery(query, sort, nextKey) { | |
const sortField = sort == null ? null : sort[0]; | |
function nextKeyFn(items) { | |
if (items.length === 0) { | |
return null; | |
} | |
const item = items[items.length - 1]; |
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
def generate_pagination_query(query, sort=None, next_key=None): | |
sort_field = None if sort is None else sort[0] | |
def next_key_fn(items): | |
if len(items) == 0: | |
return None | |
item = items[-1] | |
if sort_field is None: | |
return {'_id': item['_id']} | |
else: |
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 FragmentPagerAdapterSample(manager: FragmentManager) : FragmentPagerAdapter(manager) { | |
private val data = ArrayList<Any>() | |
fun setData(data: List<Any>) { | |
this.data.clear() | |
this.data.addAll(data) | |
notifyDataSetChanged() | |
} |
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.example | |
import com.android.volley.* | |
import com.android.volley.toolbox.HttpHeaderParser | |
import org.json.JSONException | |
import org.json.JSONObject | |
import java.io.* | |
import java.nio.charset.Charset | |
open class VolleyMultipartRequest( |