Skip to content

Instantly share code, notes, and snippets.

View Tanapruk's full-sized avatar
🎯
Focusing

Tanapruk Tanapruk

🎯
Focusing
View GitHub Profile
@Tanapruk
Tanapruk / activity.java
Created June 23, 2017 04:50
Unfocus EditText when taping outside
edittext.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus) {
Log.d("focus", "focus loosed");
// Do whatever you want here
} else {
Log.d("focus", "focused");
}
}
@Tanapruk
Tanapruk / Camera2.md
Last active October 20, 2022 07:49
Camera2 API

TextureView

You need to initialize TextureView before opening a camera. TextureView is for displaying the image from camera on the device. However, you cannot use it unless the texture is ready, either because the screen is currently off or it is initializing.

You should check mTextureView.isAvailable() before opening your camera. Else you will mTextureView.setSurfaceTextureListener(). And open your camera in the callback method onSurfaceTextureListener.

Camera

Before opening your camera you should check for a camera permission first.

@Tanapruk
Tanapruk / call-line-notify.ts
Created November 16, 2021 08:11
axios in node.js call line notify to send image
// # Requirement
// * `npm i form-data`
// # Test on node 14
--
import axios from 'axios'
import * as fs from 'fs'
import * as FormData from 'form-data'
@Tanapruk
Tanapruk / 1FileInputStreamFileOutputStream.md
Last active November 25, 2020 11:09
Input and Output Stream of Java

Page 1

I/O

When using Input or Output with java programming. We have serveral ways of implementing them. At the smallest and lowest level possible is FileInputStream and FileOutputStream. As the names describe one is for input the other is for output.

  • Input - read files/read log
  • Output - write files/print to log

FileInputStream and FileOutputStream.

@Tanapruk
Tanapruk / grid.md
Last active July 20, 2019 12:24
CSS Grid Resources
@Tanapruk
Tanapruk / jsoner.js
Created March 1, 2019 08:44
JSON.stringify remove slash double slash
function replacer(key, value) {
if (typeof value === 'string') {
//to avoid ///"
//add space to , and :
return value.replace(/"/g, '').replace(/,/g, ', ').replace(/:/g, ': ')
} else {
return value
}
}
const jsonData = JSON.stringify(data, replacer)
@Tanapruk
Tanapruk / nextjs.md
Created February 23, 2019 14:27
nextJS + Typescript development encounter.

Typescript Linting

  • You need to define type to each object if it does not exist then you need to create an interface.
  • It is what I do every now and then when developing Android app. Yet, developing in Javascript made my lazy.

Babel configurations

  • A new library may need to add a babel plugin to the .babelrc first.
  • You cannot just add a new line. Don't forget to add a dependency, too.
@Tanapruk
Tanapruk / note.md
Last active February 19, 2019 14:09
Docker

Docker

Docker's Concepts

  • image - a snapshot of environment that just work. E.g., node10:alpine This is a super small linux (alpine) os with node10 installed.
  • container - a running instance of an image. You can build container into an image and distribute the image.
  • port
    • -p 4000:80 (when using command line.)
  • "4000:80"
@Tanapruk
Tanapruk / file.sh
Created December 20, 2018 15:33
Error writing to node_modules
sudo chown -R username:group node_modules
@Tanapruk
Tanapruk / setup.md
Last active December 12, 2018 11:38
bin's devOps Workshop

create VPC

Instance Installation

Install NodeJS

  • curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash
  • . ~/.nvm/nvm.sh
  • nvm install 10.14.2
  • node -e "console.log('Running Node.js ' + process.version)"