`Long running HTTP download?`
❓️
⬇️✅️️️➡️️️➡️️️➡️️️➡️️️➡️️️➡️️️➡️️️➡️️️➡️️️➡️️️➡️️️➡️️️➡️️️➡️️️️➡️➡️️️➡️️️➡️️️➡️️️➡️️️➡️️️➡️️️➡️️️➡️️️➡️️️➡️️️➡️️️➡️️️➡️️️️➡️ DownloadManager
❎
⬇️
⬇️➡️
`Deferrable Work?`
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
```javascript | |
export const useApi = (apiRequest, initialData, depend) => { | |
// const [url, setUrl] = useState(initialUrl); | |
const [isLoading, setIsLoading] = useState(true); | |
const [hasError, setHasError] = useState(false); | |
const [errorCode, setErrorCode] = useState(200); | |
const [errorMessage, setErrorMessage] = useState(""); | |
const [fetchedData, setFetchedData] = useState(initialData); | |
useEffect(() => { |
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
(《东方早报·上海书评》,2013年3月10日) | |
十九世纪末的比利时国王利奥波德二世完全有理由成为一些人心中的偶像。他大力推动民主自由,在四十多年的任期内,把比利时从一个专制独裁国家成功变成了一个现代民主国家。他赋予每个成年男子选举权,甚至比美国提前半个世纪立法允许工人罢工。他对妇女儿童的保护领先于整个欧洲。比利时1881年就普及了基础教育,确保每个女孩都能上到初中,并且在1889年通过法律禁止十二岁以下儿童工作。在利奥波德二世治下,国家的经济像政治一样获得了大发展,他比罗斯福更早采取建设公路和铁路基础设施的手段来减少失业和刺激经济。 | |
然而在非洲刚果这个比利时殖民地,确切的说是利奥波德二世本人的殖民地,他完全是另外一个形象。刚果人,包括妇女儿童,在奥波德二世的统治下没有任何人权,完全是奴隶。他们在警察部队的强制下劳动,动辄被施以断手之类的酷刑,有超过一千万人被迫害致死,而这一切都是为了保证利奥波德二世在橡胶贸易中获得巨额利润。 | |
为什么同样一个人可以在一个国家推行民主却在另一个国家施行最残暴的独裁?有人可能立即会说这是制度问题。但“制度”在这里与其说是答案还不如说是问题本身。为什么比利时的制度越来越民主,而同一时期,同一领导人的刚果,却越来越独裁?难道是因为利奥波德二世只爱本国人或者有种族歧视?但后来刚果自己“选”出来的领导人并没有做得更好,仍然是一个糟糕的独裁者。在The Predictioneer’s Game(《预测师的博弈论》)这本书里,斯坦福大学胡佛研究所和纽约大学的政治学教授Bruce Bueno de Mesquita指出,真正原因是在刚果,利奥波德二世只需要让少数人高兴就足以维持自己的统治;而在比利时,他必须让很多人满意才行。我认为这个答案跟“制度论”的区别在于必须让多少人满意,这个人数不是制度“规定”出来的,而是实力的体现。 | |
Bueno de Mesquita和合作者研究多年,得出了一个能够相当完美地解释很多政治现象的理论。这个理论认为不管是国家、公司还是国际组织,其政治格局不能简单地以“民主”和“独裁”来划分,而必须用三个数字来描写。以国家为例,这个“三围”就是层层嵌套的三种人的人数: |
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
// https://engineering.rallyhealth.com/android/code-coverage/testing/2018/06/04/android-code-coverage.html | |
ext.enableJacoco = { Project project, String variant -> | |
project.plugins.apply('jacoco') | |
final capVariant = variant.capitalize() | |
StringBuilder folderSb = new StringBuilder(variant.length() + 1) | |
for (int i = 0; i < variant.length(); i++) { | |
char c = variant.charAt(i) |
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
// with just a simple extension function for the Data Binding ObservableField | |
inline fun <R> ObservableField<R>.observe(crossinline callback: (R) -> Unit) { | |
this.addOnPropertyChangedCallback(object : Observable.OnPropertyChangedCallback() { | |
override fun onPropertyChanged(p0: Observable?, p1: Int) { | |
callback(get()) | |
} | |
}) | |
} | |
... |
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
fun checkToSix() { | |
val list = ArrayList<String>() | |
// val src = listOf(2,2,2) | |
(2..9) | |
.map { | |
System.out.println(it) | |
listOf(it, it, it) | |
} | |
.forEach { | |
list.clear() |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
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
ffmpeg started on 2016-07-20 at 23:25:03 | |
Report written to "/storage/emulated/0/Android/data/com.garena.videodemo/cache/comp_VID_20160703_172409.mp4.log" | |
Command line: | |
ffmpeg -y -i /storage/emulated/0/Download/VID_20160703_172409.mp4 -crf 33 -preset ultrafast -loglevel trace /storage/emulated/0/Android/data/com.garena.videodemo/cache/comp_VID_20160703_172409.mp4 | |
ffmpeg version 3.0.1 Copyright (c) 2000-2016 the FFmpeg developers | |
built with gcc 4.9 (GCC) 20140827 (prerelease) | |
configuration: --target-os=linux --arch=x86 --cpu=i686 --enable-yasm --enable-cross-compile --cross-prefix=i686-linux-android- --prefix=/Users/zhangzf/android/libs/gcodec/external/build/x86 --sysroot=/Users/zhangzf/android/libs/gcodec/external/build/x86/toolchain/sysroot --enable-small --enable-static --disable-shared --enable-pic --enable-asm --enable-inline-asm --enable-gpl --enable-libx264 --disable-doc --disable-symver --disable-gray --disable-swscale-alpha --disable-hwaccels --disable-iconv --disable-programs --disable-ffmpeg --d |
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
BufferedReader br = null; | |
try { | |
br = new BufferedReader( | |
new FileReader(output.getAbsolutePath() + ".log")); | |
String line; | |
double totalSecs = 0; | |
double totalFps = 0; | |
while (keepReading) { | |
line = br.readLine(); | |
if (line == null) { |
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
android.applicationVariants.all { variant -> | |
def applicationId = variant.applicationId | |
def adb = androidadbExe. as String | |
def variantName = variant.name.capitalize() | |
def grantPermissionTask = task.create("create${variantName}Permissions") << { | |
"${adb} devices".execute().text.eachLine { | |
if(it.endsWith("device")){ | |
def device = it.split()[0] | |
println "Granting permissions on devices ${device}" | |
"${adb} -s ${devices} shell pm grant ${applicationId} android.permission.ACCESS_FINE_LOCATION".execute() |
NewerOlder