Table of Contents
fun <T> Flow<T>.throttle(waitMillis: Int) = flow { | |
coroutineScope { | |
val context = coroutineContext | |
var nextMillis = 0L | |
var delayPost: Deferred<Unit>? = null | |
collect { | |
val current = SystemClock.uptimeMillis() | |
if (nextMillis < current) { | |
nextMillis = current + waitMillis |
//First, define a custom bundle class as like as below | |
import Foundation | |
//A key used for exchanging associated object | |
var _BUNDLE_KEY = 0 | |
class BundleEx : Bundle { | |
override func localizedString(forKey key: String, value: String?, table tableName: String?) -> String { |
import java.util.* | |
/** | |
* Created by yangwei-ms on 2017/7/14. | |
*/ | |
class SkipList<T>(private val comparator: Comparator<T>) { | |
private var curHeight: Int = 1 | |
private val head: Node<T> = Node(null, MAX_HEIGHT) | |
private val rnd: Random = Random(System.currentTimeMillis()) |
data class User(@JsonProperty("userName") val name: String) | |
val userObj = User("John") | |
JsoniterKotlinSupport.enable() | |
JsoniterAnnotationSupport.enable() | |
val jsonUserString = JsonStream.serialize(userObj) | |
// jsonUserString will contain: {"userName":"John"} |
private static OkHttpClient getUnsafeOkHttpClient() { | |
try { | |
// Create a trust manager that does not validate certificate chains | |
final TrustManager[] trustAllCerts = new TrustManager[]{ | |
new X509TrustManager() { | |
@Override | |
public void checkClientTrusted(java.security.cert.X509Certificate[] chain, | |
String authType) throws CertificateException { | |
} |
#Progress in C
This is in an example meant to present some ideas regarding command-line progress bars in C.
##Important parts
The main idea is to overwrite stdout
with new information every time a particular step is reached. I accomplished this using the VT100 emulator hack from [this Stack Overflow answer][1]. In a nutshell, printing ^[[2K
to stdout
erases the current line, but it doesn't necessarily move the cursor to the start. Printing \r
does that. Also, I decided I wanted to print a newline character after the progress indicator, but I need to get rid of that newline on the next print. That's what \b
does: it inserts a backspace, deleting the last character printed.
Also important is the call to fflush
, which will guarantee that the print operation completes and is visible before the program moves on to its next task (see [this Stack Overflow answer][2]).
These commands are based on a askubuntu answer http://askubuntu.com/a/581497 | |
To install gcc-6 (gcc-6.1.1), I had to do more stuff as shown below. | |
USE THOSE COMMANDS AT YOUR OWN RISK. I SHALL NOT BE RESPONSIBLE FOR ANYTHING. | |
ABSOLUTELY NO WARRANTY. | |
If you are still reading let's carry on with the code. | |
sudo apt-get update && \ | |
sudo apt-get install build-essential software-properties-common -y && \ | |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \ |
/* | |
* Copyright (C) 2016 Jeff Gilfelt. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
First of all, this is not my brilliant effort to get react-native working on Windows, it is the collation of work by others, particularly @mqli and @Bernd Wessels. I've just summarised what worked for me.
If you would prefer to read what I've plagerised, head over to mqli's great gist
- The below is tested with
react-native-cli 0.1.5
,react-native 0.12.0
on Windows 10, node 4.1.1, and Android (physical Nexus 6 and AVD with API v22) - I hope this will all be redundant in a few weeks. Please comment on stuff that is now fixed and I will update this to keep it relevant.
- Sprinkle a bit of YMMV around
Keep this github issue handy, it’s the bucket for all Windows/Linux related tricks to get RN working.