Skip to content

Instantly share code, notes, and snippets.

View tomoima525's full-sized avatar
🎯
Focusing

tomo tomoima525

🎯
Focusing
View GitHub Profile
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 => {
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');
});
});
@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;
@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 / 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 / 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)
{
"aps" : {
"alert" : {
"title" : "Game Request",
"body" : "Bob wants to play poker",
"action-loc-key" : "PLAY"
},
"badge" : 5
},
"acme1" : "bar",
@tomoima525
tomoima525 / CustomNativeModule.kt
Created December 18, 2020 09:09
Replace ReactPackage with TurboReactPackage
// ReactModule annotation is required to create reactModuleInfoMap
@ReactModule(name = "CustomBackground")
class CustomBackgroundNativeModule(context: ReactApplicationContext): ReactContextBaseJavaModule(context) {
override fun getName(): String = "CustomBackground"
@ReactMethod
fun hide() {}
@ReactMethod
fun show() {}
@tomoima525
tomoima525 / playground.rs
Created September 17, 2021 18:11 — forked from rust-play/playground.rs
Code shared from the Rust Playground
// use std::cell::RefCell;
// Ownership
use {
std::ops::Drop
};
#[derive(Debug)]
struct Parent(usize, Child, Child);
#[derive(Debug)]
@tomoima525
tomoima525 / playground-2.rs
Last active September 17, 2021 21:35 — forked from rust-play/playground.rs
Code shared from the Rust Playground
// use std::cell::RefCell;
// Ownership: Copy semantic
// Copy trait should not have Drop trait implemented
#[derive(Debug, Clone, Copy)]
struct Parent(usize, Child, Child);
#[derive(Debug, Clone, Copy)]
struct Child(usize);