Skip to content

Instantly share code, notes, and snippets.

View tomoima525's full-sized avatar
🎯
Focusing

tomo tomoima525

🎯
Focusing
View GitHub Profile
@tomoima525
tomoima525 / curl.md
Created December 2, 2022 21:02 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@tomoima525
tomoima525 / blerp.js
Created November 8, 2022 18:00 — forked from botagar/blerp.js
Javascript implementation of Bilinear Interpolation
Math.blerp = function (values, x1, y1, x2, y2, x, y) {
let q11 = (((x2 - x) * (y2 - y)) / ((x2 - x1) * (y2 - y1))) * values[x1][y1]
let q21 = (((x - x1) * (y2 - y)) / ((x2 - x1) * (y2 - y1))) * values[x2][y1]
let q12 = (((x2 - x) * (y - y1)) / ((x2 - x1) * (y2 - y1))) * values[x1][y2]
let q22 = (((x - x1) * (y - y1)) / ((x2 - x1) * (y2 - y1))) * values[x2][y2]
return q11 + q21 + q12 + q22
}
@tomoima525
tomoima525 / playground.rs
Last active September 18, 2021 06:48 — forked from rust-play/playground.rs
Code shared from the Rust Playground
// Implementing Vector
pub struct ToyVec<T> {
elements: Box<[T]>,
len: usize,
}
// Reference type field requires lifetime specifier
pub struct Iter<'vec, T> {
elements: &'vec Box<[T]>,
len: usize,
@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);
@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 / 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() {}
{
"aps" : {
"alert" : {
"title" : "Game Request",
"body" : "Bob wants to play poker",
"action-loc-key" : "PLAY"
},
"badge" : 5
},
"acme1" : "bar",
@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