Skip to content

Instantly share code, notes, and snippets.

View hwshim0810's full-sized avatar

Hyunwoo Shim hwshim0810

View GitHub Profile
@hwshim0810
hwshim0810 / blur.kt
Created July 3, 2018 15:56
android image blur
import android.content.Context
import android.graphics.Bitmap
import android.os.Build
import android.renderscript.Allocation
import android.renderscript.Element
import android.renderscript.RenderScript
import android.renderscript.ScriptIntrinsicBlur
fun blur(context: Context, sourceBitmap: Bitmap, radius: Float): Bitmap {
@hwshim0810
hwshim0810 / className.java
Created June 28, 2018 02:35
Get launch class name
Context context = getContext();
context.getPackageManager().getLaunchIntentForPackage(context.getPackageName()).getComponent().getClassName();
@hwshim0810
hwshim0810 / click.java
Created June 26, 2018 04:36
Android prevent duplicate click
private long mLastClickTime = 0L;
findViewById(R.id.button)
.setOnClickListener(new OnClickListener() {
@Override public void onClick(View v) {
// mis-clicking prevention :: 1000 ms
if (SystemClock.elapsedRealtime() - mLastClickTime < 1000) return;
mLastClickTime = SystemClock.elapsedRealtime();
}
});
@hwshim0810
hwshim0810 / cookie.js
Created May 24, 2018 07:13
Javascript getCookie functions
@hwshim0810
hwshim0810 / divider.scss
Created May 20, 2018 14:17
Grey line divider
.divider {
text-transform: uppercase;
color: $dark-grey;
font-weight: 600;
margin: 20px 0;
position: relative;
&:before,
&:after {
content: "";
@hwshim0810
hwshim0810 / mixin.scss
Created May 20, 2018 14:16
responsive mixin
$tablet-width: 768px;
$desktop-width: 875px;
$xl-desktop-width: 1351px;
$phone-width: 320px;
$iphone6-width: 375px;
$iphone6plus-width: 450px;
@mixin breakpoint($breakpoint) {
@if $breakpoint == "tablet" {
@media (min-width: #{$iphone6plus-width}) and (max-width: #{$desktop-width}) {
@hwshim0810
hwshim0810 / mixin.scss
Created May 20, 2018 14:12
Simple responsive mixin
@mixin breakpoint($point) {
@if $point == desktop {
@media (min-width: 70em) {
@content;
}
}
@else if $point == laptop {
@media (min-width: 64em) {
@content;
}
@hwshim0810
hwshim0810 / function.py
Created May 17, 2018 11:08
Get if int or rounded float
def get_if_int_or_float(value, under_num=1):
return int(value) if value.is_integer() else round(value, under_num)
@hwshim0810
hwshim0810 / onback.kt
Created May 14, 2018 14:26
onBackPressed with rxjava :: in presenter
private val backButtonSubject: Subject<Long> = BehaviorSubject.createDefault(0L).toSerialized()
private val backButtonSubjectDisposable =
compositeDisposable.add(backButtonSubject.toFlowable(BackpressureStrategy.BUFFER)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) // need compose
.buffer(2, 1)
.map { it[0] to it[1] }
.subscribe({ value ->
if (value.second - value.first < 2000) getView()?.finishView()
@hwshim0810
hwshim0810 / modal.html
Created April 24, 2018 15:41
Bootstrap modal example
<a href="#modalBox" data-toggle="modal">OpenButton</a>
<div class="modal fade" id="modalBox" tabindex="-1" role="dialog" aria-labelledby="modal-label" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="modal-label">
Title Area
</h4>