본문 바로가기

분류 전체보기274

[ANDROID] java.lang.IllegalArgumentException: Comparison method violates its general contract! 앱을 실행시켜놓고 아침에 와서 봤더니 다음과 같은 에러가 나고 제대로 실행이 안되고 있었다... FATAL EXCEPTION: inference java.lang.IllegalArgumentException: Comparison method violates its general contract! at java.util.TimSort.mergeLo(TimSort.java:777) at java.util.TimSort.mergeAt(TimSort.java:514) at java.util.TimSort.mergeCollapse(TimSort.java:441) at java.util.TimSort.sort(TimSort.java:245) at java.util.Arrays.sort(Arrays.java:1498.. 2020. 12. 4.
[ANDROID] 두 점의 각도 구하기 두 점의 각도 구하는 방법 public static double angleOf(PointF p1, PointF p2) { // NOTE: Remember that most math has the Y axis as positive above the X. // However, for screens we have Y as positive below. For this reason, // the Y values are inverted to get the expected results. final double deltaY = (p1.y - p2.y); final double deltaX = (p2.x - p1.x); final double result = Math.toDegrees(Math.atan2(deltaY,.. 2020. 11. 17.
[ANDROID] base64 string 변환 public static String getBase64String(Bitmap bitmap) { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream); byte[] imageBytes = byteArrayOutputStream.toByteArray(); return Base64.encodeToString(imageBytes, Base64.NO_WRAP); } String encoded = android.util.Base64.encodeToString(bytes, android.util.Base64... 2020. 10. 29.
[ANDROID] drawable 파일 bitmap 변환 public static Bitmap drawableToBitmap(Drawable drawable) { Bitmap bitmap = null; try { if (drawable instanceof BitmapDrawable) { BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; if (bitmapDrawable.getBitmap() != null) { return bitmapDrawable.getBitmap(); } } if (drawable.getIntrinsicWidth() 2020. 10. 29.
[ANDROID] dp 값 px 변환 public static float dipToPixels(Context context, float dipValue) { DisplayMetrics metrics = context.getResources().getDisplayMetrics(); return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dipValue, metrics); } 2020. 10. 29.
[ANDROID] bitmap byte array 변환 public static byte[] bitmapToByteArray( Bitmap bitmap ) { ByteArrayOutputStream stream = new ByteArrayOutputStream() ; bitmap.compress( Bitmap.CompressFormat.PNG, 100, stream) ; byte[] byteArray = stream.toByteArray() ; return byteArray ; } public static Bitmap byteArrayToBitmap(byte[] bytearr) { return BitmapFactory.decodeByteArray(bytearr, 0, bytearr.length); } 2020. 10. 29.
[NODEJS] pm2 설치 및 사용 0. 설치 npm install pm2 -g pm2 install pm2-logrotate pm2 set pm2-logrotate:compress true 1. 프로세스 체크 pm2 list | grep main | grep online pm2-logrotate 세팅 pm2 set pm2-logrotate:compress true 2. 프로세스 시작 및 로그 저장 pm2 start /home/app/main.js -o /home/contents/log/main_out.log -l /home/contents/log/main_log.log 3. 종료 pm2 kill 4. 테스트 용도 세팅 pm2 set pm2-logrotate:rotateInterval '*/1 * * * *' 2020. 10. 29.
[MARIADB] 설치 [MARIA DB] apt install mariadb-server apt install libmariadbclient-dev >> libmariadbclient.so 파일이 생성이 되어야함. ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock * 유저 생성 및 권한 sudo mariadb -u root use mysql; create user 'root'@'%' identified by 'root'; grant all privileges on *.* to 'root'@'%' identified by 'root'; FLUSH PRIVILEGES; * 권한 sudo mariadb -u root use mysql; grant all privileges on *.* to .. 2020. 10. 29.
[꿀팁] 메모리 확인 while true; do cat /proc/{프로세스ID}/status | grep VmRSS; sleep 1; done 명령어를 치면 1초마다 메모리 확인 가능. 디버깅 시 유용. 2020. 10. 29.
[GOLANG] 공부 (4) ● s라는 문자열 내에서 각각의 "단어"의 등장 횟수를 나타내는 맵 반환 함수 import "strings" func WordCount(s string) map[string]int { wordString := make(map[string]int) for _,word := range strings.Fields(s) { wordString[word]++ } return wordString } *스위치 (Switch) - case의 코드 실행을 마치면 알아서 break 함 > fallthrough로 끝나는 case는 스스로 break를 하지 않음. switch os := runtime.GOOS; os { case "darwin": fmt.Println("OS X.") case "linux": fmt.Print.. 2020. 10. 29.