Skip to content

Instantly share code, notes, and snippets.

View akueisara's full-sized avatar
🎹

Kuei-Jung Hu akueisara

🎹
View GitHub Profile
@akueisara
akueisara / Minimum Spanning Trees.md
Last active August 10, 2017 11:02
Week 5 of Coursera's Algorithms on Graphs

Minimum Spanning Trees

1. Building a Network

1-1. Minimum spanning tree (MST)

  • Input: A connected, undirected graph G = (V , E) with positive edge weights.
  • Output: A subset of edges E′ ⊆ E of minimum total weight such that the graph (V , E′) is connected.

Remark

The set E′ always forms a tree.

1-2. Properties of Trees

@akueisara
akueisara / 1. Bidirectional Dijkstra.md
Last active August 10, 2017 10:55
Week 6 of Coursera's Algorithms on Graphs

Bidirectional Dijkstra

1. Bidirectional Search

1.1 Shortest Path

  • Input: A graph G with non-negative edge weights, a source vertex s and a target vertex t.
  • Output: The shortest path between s and t in G.

1.2 Why not just Dijkstra?

  • O((|E| + |V |)log |V |) is pretty fast, right?
  • For a graph of USA with 20M vertices and 50M edges it will work for several seconds on average
  • Millions of users of Google Maps want the result in a blink of an eye, all at the same time
@akueisara
akueisara / design_patterns.md
Last active August 21, 2024 07:51
Design Patterns by University of Alberta

Design Patterns

Week 1

1. Gang of Four's Pattern Catalogue

Design Patterns: Elements of Reusable Object-Oriented Software – Gamma, Helm, Johnson, and Vlissides

2. Categories of Patterns

@akueisara
akueisara / getLanguage.kt
Last active April 3, 2019 11:03
How to get if the default language is Simplified or Traditional Chinese on Android devices in Kotlin
private fun getLanguage(): String {
val lang = Locale.getDefault().language
val country = Locale.getDefault().country
val langTag = Locale.getDefault().toLanguageTag()
if(lang.contains("zh")) {
if(country == "TW") {
return "Traditional Chinese"
} else {
if(langTag.contains("Hant")) {
return "Traditional Chinese"
@akueisara
akueisara / eample.xml
Last active December 22, 2019 03:52
Add spacing between the lines using the lineSpacingMultiplier property to the TextView
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lineSpacingMultiplier="1.2"/>
@akueisara
akueisara / hide_keyboard_on_android.kt
Created December 22, 2019 03:48
Hint: In your click handler, add this code to hide the keyboard after input is complete:
// Hide the keyboard.
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(view.windowToken, 0)
@akueisara
akueisara / fade_in.xml
Created December 22, 2019 04:23
Useful animate transitions between destinations on Android
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright 2018, The Android Open Source Project
~
~ 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
@akueisara
akueisara / Developing Android Apps Notes.md
Last active March 15, 2020 12:36
Android Development Notes from Udacity Android Courses

Intro

Android Min and Target Versions

  • The minSDK is the lowest SDK level that your app can run on. Remember that each release introduced new APIs and hardware support, so it may not make sense to make your app available to devices that don’t support your minimum feature set. Here are some examples of hardware support and features, tied to releases.
    • Home screen widgets (Cupcake)
    • Multiple finger tracking (Froyo)
    • Tablet (Honeycomb)
    • Android Beam(NFC) and BLE (Jellybean)
    • Android TV, Auto, Wear (Lollipop)
    • Pro Audio (Marshmallow)
  • By comparison, the targetSDK is NOT a high pass filter -- it’s used only to declare which platform version you've tested your app on. An app targeted to a certain API or Android version will continue to be forward compatible on future releases -- the platform uses the target SDK values in case a future release makes a significant change to expected behavior, ensuring your app doesn’t break when a user’s phone gets upgraded.
@akueisara
akueisara / Intents and Sharing.md
Last active March 17, 2020 15:24
Android Notes

Explicit Intents launch specific activity.

Implicit Intents specify WHAT you want done and system chooses activity.

Intent Action: the type of thing that the app wants to have done on its behalf, such as ACTION_VIEW, ACTION_DIAL or ACTION_EDIT

Intent Category adds a subtype to the action, such as CATEGORY_APP_MUSIC, CATEGORY_APP_GALLERY, CATEGORY_APP_MAPS, CATEGORY_APP_CALCULATOR, CATEGORY_APP_EMAIL, CATEGORY_APP_CALENDAR

**Intent Data Type (MIME Data Type) ** allows activities to support specific data types.

@akueisara
akueisara / Animations.kt
Last active April 16, 2020 06:21
Android Property Animations Code Snippets (Udacity)
private fun ObjectAnimator.disableViewDuringAnimation(view: View) {
addListener(object : AnimatorListenerAdapter() {
override fun onAnimationStart(animation: Animator?) {
view.isEnabled = false
}
override fun onAnimationEnd(animation: Animator?) {
view.isEnabled = true
}
})