Skip to content

Instantly share code, notes, and snippets.

View wangyung's full-sized avatar

Freddie Wang wangyung

View GitHub Profile
@wangyung
wangyung / keybase.md
Created January 29, 2018 03:13
for keybase

Keybase proof

I hereby claim:

  • I am wangyung on github.
  • I am wangyung (https://keybase.io/wangyung) on keybase.
  • I have a public key ASA2q2N6lgS50GIUEpSsBaRs_684iOmm-gZRXkxkX45Ddwo

To claim this, I am signing this object:

@wangyung
wangyung / adb_tips.sh
Created April 23, 2019 06:45
adb tips
# Launch developer options.
adb shell am start -a android.settings.APPLICATION_DEVELOPMENT_SETTINGS
@wangyung
wangyung / description.md
Created May 6, 2019 10:35 — forked from dmytrodanylyk/description.md
Where this dependency comes from?

Did you ever have android build failed​ issue because of dependency resolution?

… or you were curious where all these old rxjava dependencies come from?

You can pretty easy track the module causing issues via following gradle command.

gradlew :root-module:dependencyInsight \
--configuration debugRuntimeClasspath \ // or debugCompileClasspath
--dependency io.reactivex:rxjava:1.1.0 > dependencies.txt // saves result to 'dependencies.txt' file
@wangyung
wangyung / scan_all_files.kt #for_medium
Last active September 14, 2020 15:41
Pseudo code for scanning all files and get the cover image.
private fun scanDirectory(directory: Path) {
Files
.walk(directory)
.filter {
Files.isDirectory(it, LinkOption.NOFOLLOW_LINKS)
}.forEach {
scope.launch { readBooksFromPath(it) }
}
}
@wangyung
wangyung / animate_overlay.kt
Last active February 24, 2020 01:31
The example of how to animate the tile overlay on google maps
fun animateTileOverlay() {
overlay?.remove() // Remove previous overlay
overlay = map.addTileOverlay(
TileOverlayOptions()
.tileProvider(tileProvider)
.fadeIn(false)
.zIndex(zIndex)
)
}
@wangyung
wangyung / swap_overlay.kt
Created February 24, 2020 01:32
The example of how to animate tile overlay and decrease the flickers
private fun swapTiles() {
if (overlay1 != null) {
overlay2 = map.addTileOverlay(
TileOverlayOptions()
.tileProvider(timedTileProvider)
.fadeIn(false)
.zIndex(zIndex)
)
removeOverlay(overlay1) {
overlay1 = null
@wangyung
wangyung / CoroutineScheduler.kt
Created March 5, 2020 05:40
The dispatch function in CoroutineScheduler.kt
fun dispatch(block: Runnable, taskContext: TaskContext = NonBlockingContext, fair: Boolean = false) {
trackTask() // this is needed for virtual time support
val task = createTask(block, taskContext)
// try to submit the task to the local queue and act depending on the result
val notAdded = submitToLocalQueue(task, fair)
if (notAdded != null) {
if (!addToGlobalQueue(notAdded)) {
// Global queue is closed in the last step of close/shutdown -- no more tasks should be accepted
throw RejectedExecutionException("$schedulerName was terminated")
}
@wangyung
wangyung / get-image-urls.js
Created April 13, 2020 00:08 — forked from tobek/get-image-urls.js
Save images from chrome inspector/dev tools network tab
/* open up chrome dev tools (Menu > More tools > Developer tools)
* go to network tab, refresh the page, wait for images to load (on some sites you may have to scroll down to the images for them to start loading)
* right click/ctrl click on any entry in the network log, select Copy > Copy All as HAR
* open up JS console and enter: var har = [paste]
* (pasting could take a while if there's a lot of requests)
* paste the following JS code into the console
* copy the output, paste into a text file
* open up a terminal in same directory as text file, then: wget -i [that file]
*/
@wangyung
wangyung / change_name.sh
Last active September 14, 2020 15:32
Change all file names by incremental number. #tips
#!/bin/bash
INDEX=1
for file in `ls | sort -g`
do
filename=$(basename "$file")
extension=${filename##*.}
filename=$(printf "%03d\n" $INDEX)
mv "$file" "$filename.$extension"
@wangyung
wangyung / enable_photo_viewer.reg
Created April 13, 2021 08:03
Enable windows photo viewer
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Photo Viewer\Capabilities\FileAssociations]
".tif"="PhotoViewer.FileAssoc.Tiff"
".tiff"="PhotoViewer.FileAssoc.Tiff"
".gif"="PhotoViewer.FileAssoc.Tiff"
".jpg"="PhotoViewer.FileAssoc.Tiff"
".jpeg"="PhotoViewer.FileAssoc.Tiff"
".webp"="PhotoViewer.FileAssoc.Tiff"
".png"="PhotoViewer.FileAssoc.Tiff"