Skip to content

Instantly share code, notes, and snippets.

View harryhan24's full-sized avatar

harry han harryhan24

View GitHub Profile
abstract class BaseFragment<VB : ViewDataBinding, VM : BaseViewModel> : DaggerFragment() {
abstract fun getViewModelClass(): Class<VM>
abstract fun layoutId(): Int
@Inject
lateinit var viewModelFactory: ViewModelProvider.Factory
protected lateinit var binding: VB
protected lateinit var viewModel: VM
@harryhan24
harryhan24 / AnkoExtensions.kt
Created August 4, 2018 07:28 — forked from baeyeongpyo/AnkoExtensions.kt
Anko Stream Extensions
inline fun <V : View> V.alpha(alpha: Double): V {
this.alpha = alpha.toFloat()
return this
}
inline fun <V : View> V.backgroundColor(color: Int): V {
backgroundColor = color
return this
}
class AnkoUIMaker(val context: Context) {
private val constraintlayoutID = R.id.ankoConstraintLayout
fun UiMake(): View =
context.constraintLayout {
id = constraintlayoutID
// 추가
textView("Anko Hello").lparams(wrapContent, wrapContent) {
startToStart = constraintlayoutID
endToEnd = constraintlayoutID
topToTop = constraintlayoutID
class AnkoViewHolder<out V : AnkoComponent<ViewGroup>>(val parent: ViewGroup, val createUI: () -> V) {
class ViewHolder<out V : AnkoComponent<ViewGroup>>(val view: View, val ui: V) : RecyclerView.ViewHolder(view)
val ankoContext by lazy { AnkoContext.createReusable(parent.context, parent) }
val viewHolder by lazy {
val ui = createUI()
val view = ui.createView(ankoContext)
view.setupTapEffectForBG(true) // default for every item in application
// TODO some items may be disabled...
ViewHolder(view, ui)
@harryhan24
harryhan24 / serverless.yml
Created July 21, 2018 02:58 — forked from DavidWells/serverless.yml
DynamoDB custom index serverless.yml example
service: service-name
provider:
name: aws
runtime: nodejs6.10
functions:
myfunc:
handler: handler.myfunc
@harryhan24
harryhan24 / Extensions.kt
Created July 2, 2018 15:44 — forked from albertogiunta/Extensions.kt
Extension functions (Kotlin) & build.gradle files for Android projects
/**
* ANY
*/
fun Any.toJson(): String = GsonInitializer.toJson(this)
/**
* VIEW
*/
fun View.toggleVisibility(setAsVisible: Boolean) = if (setAsVisible) this.visible() else this.gone()
@harryhan24
harryhan24 / build.gradle
Created June 28, 2018 14:38 — forked from davebren/build.gradle
gradle flavors and resources example
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 23
@harryhan24
harryhan24 / sns-to-slack.js
Created June 7, 2018 14:40 — forked from benyanke/sns-to-slack.js
AWS Lambda function for forwarding SNS notifications to Slack
// Added by Ben Yanke
// from https://gist.github.com/benyanke/862e446e5a816551928d8acc2d98b752
console.log('Loading function');
const https = require('https');
const url = require('url');
// SETUP
// urlToUse = in this environment variable, place the name of another environment variable which contains the key.
// This allows easy dev/prod switching.
@harryhan24
harryhan24 / STSTesting.scala
Created June 2, 2018 18:36 — forked from chrishowell/STSTesting.scala
Using STS with MFA and longer lived session credentials
import com.amazonaws.auth.profile.internal.{BasicProfile, ProfileStaticCredentialsProvider}
import com.amazonaws.auth.profile.{ProfileCredentialsProvider, ProfilesConfigFile}
import com.amazonaws.auth.{AWSCredentials, AWSCredentialsProvider, AWSStaticCredentialsProvider, BasicSessionCredentials, DefaultAWSCredentialsProviderChain}
import com.amazonaws.services.s3.AmazonS3ClientBuilder
import com.amazonaws.services.securitytoken.model.{AssumeRoleRequest, GetSessionTokenRequest}
import com.amazonaws.services.securitytoken.{AWSSecurityTokenServiceClient, AWSSecurityTokenServiceClientBuilder}
import scala.collection.JavaConversions._
object STSTesting {