Skip to content

Instantly share code, notes, and snippets.

View tomoima525's full-sized avatar
🎯
Focusing

tomo tomoima525

🎯
Focusing
View GitHub Profile
@tomoima525
tomoima525 / getResizedBitmap.kt
Created February 5, 2020 08:45
resize bitmap
suspend fun getResizedBitmap(bm: Bitmap, newWidth: Int, newHeight: Int): Bitmap {
return withContext(Dispatchers.IO) {
val width = bm.width
val height = bm.height
val scaleWidth = newWidth.toFloat() / width
val scaleHeight = newHeight.toFloat() / height
val matrix = Matrix()
matrix.postScale(scaleWidth, scaleHeight)
@tomoima525
tomoima525 / test.js
Created January 15, 2020 23:12
arrow function to call this context
const materials = [
'Hydrogen',
'Helium',
'Lithium',
'Beryllium'
];
class Test {
test = (material) => { // test(material) would show error this.test2 is not a function
@tomoima525
tomoima525 / bug_investigation.md
Created December 4, 2019 01:08
Bug investigation on RN
  1. Check the behavior and logs
  • Check any suspicious error is showing up on log
  1. Check the setting on Android
  • Check any settings are missing on the file below
    • settings.gradle, build.gradle, app/build.gradle, MainApplication.java, MainActivity.java
  1. Read documents
  • Create RN project from scratch and check the diff between our project
  • Check document of CodePush and React Native Navigation(which are the largest diff on the Native side)
  1. Simplify/breakdown codebase to triage the bug
  • Remove anything related to React Native Navigation
@tomoima525
tomoima525 / yogaFragment.java
Created November 3, 2019 02:44
Yoga sample code for Android
package com.koudle.andyogaexample.fragments;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import formatDateToUTC from '../utils/format_date_to_utc';
describe('formatDateToUTC', () => {
test('should format date to UTC time zone', () => {
const date = new Date('May 9, 2019 11:33:30 GMT-07:00'); // Pacific Day Light Time
expect(formatDateToUTC(date)).toEqual('201905091833');
});
});
const formatDateToUTC = date => {
const month = `${date.getUTCMonth() + 1}`;
const day = `${date.getUTCDate()}`;
const hour = `${date.getUTCHours()}`;
const min = `${date.getUTCMinutes()}`;
const year = `${date.getFullYear()}`;
const list = [year, month, day, hour, min];
return list
.map(v => {
@tomoima525
tomoima525 / clear.txt
Created October 18, 2018 07:31 — forked from EQuimper/clear.txt
React-Native clear Watchman + Cache
watchman watch-del-all && rm -rf node_modules/ && yarn cache clean && yarn install && yarn start -- --reset-cache
@ReactMethod
fun generate(imagePath: String,
renderSettings: ReadableArray,
width: Int,
height: Int,
promise: Promise
) {
Log.d("Thumbnail", "====== called $renderSettings $imagePath")
launch(CommonPool) {
try {
@tomoima525
tomoima525 / installFromBundle
Created July 12, 2018 19:01 — forked from keyboardsurfer/installFromBundle
Build & extract a set of apk from an aab for a specific device and install the results on it.
#!/bin/sh
# Build & extract a set of apk from an aab for a specific device and install the results on it.
#
# This needs https://github.com/google/bundletool to be available as `bundletool`.
# Also **exactly** one device needs to be connected to adb.
# Usage: installFromBundle bundle.aab
# optional `--extract-apks` to keep the set on your workstation as well.
basename=${1%%.*}
keystore="~/.android/debug.keystore"