Failed to get lock on destination repos, currently held by ‘ubuntu:9f51b9fe-b204-4439-a0d5-88a2fd5d5ff6’

Problem

  1. water@ubuntu:/xxxxxxxxxxsvnsync$ svnsync sync --non-interactive file:////XXX/XXXX/XXXXXXXXXXX/XXXXXXXXXXXXXXXXXXX
  2. Failed to get lock on destination repos, currently held by 'ubuntu:9f51b9fe-b204-4439-a0d5-88a2fd5d5ff6'

Resolved

  1. water@ubuntu:/xxxxxxxxxxsvnsync$ svnsync sync --non-interactive file:////XXX/XXXX/XXXXXXXXXXX/XXXXXXXXXXXXXXXXXXX --steal-lock
  2. Stole lock previously held by 'ubuntu:9f51b9fe-b204-4439-a0d5-88a2fd5d5ff6'

Install Qt 5.12.10 on Ubuntu 18.04

  1. cp qt-opensource-linux-x64-5.12.10.run ~/Downloads/
  2. cd ~/Downloads/
  3. ./qt-opensource-linux-x64-5.12.10.run
  4. sudo apt-get install libxcb-xinerama0
  5. sudo apt-get install build-essential
  6. sudo apt-get install libfontconfig1
  7. sudo apt-get install mesa-common-dev
  8. sudo apt-get install libglu1-mesa-dev -y

Android keystore jks pk8 x509.pem

Lists entries in a keystore

  1. keytool -list -v -keystore platform.keystore

Generate Signed APK Using jarsigner

  1. jarsigner -verbose -keystore platform.keystore -signedjar app-debug-signed.apk app-debug.apk alias-name

pk8 & x509.pem -> keystore

  1. ./keytool-importkeypair -k ./oldplatform.keystore -p password -pk8 ../platform.pk8 -cert ../platform.x509.pem -alias alias-name

keystore -> p12 -> jks

  1. keytool -importkeystore -srckeystore platform.keystore -srcstoretype JKS -deststoretype PKCS12 -destkeystore platform.keystore.p12
  2. keytool -v -importkeystore -srckeystore platform.keystore.p12 -srcstoretype PKCS12 -destkeystore platform.keystore.jks -deststoretype JKS

Generate Signed APK Using Android Studio


Using X11 for GUI

Result

Code

  1. #include <X11/Xlib.h>
  2. #include <X11/Xlocale.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6.  
  7. void
  8. DrawCenteredMbString(Display* dpy, Window w, XFontSet fontset, GC gc, char* str, int num_bytes, int x, int y, int width,
  9. 	int height) {
  10. 	XRectangle boundingbox;
  11. 	XRectangle dummy;
  12. 	int originx, originy;
  13.  
  14. 	(void)XmbTextExtents(fontset, str, num_bytes, &dummy, &boundingbox);
  15.  
  16. 	originx = x + (width - boundingbox.width) / 2 - boundingbox.x;
  17. 	originy = y + (height - boundingbox.height) / 2 - boundingbox.y;
  18.  
  19. 	XmbDrawString(dpy, w, fontset, gc, originx, originy, str, num_bytes);
  20. }
  21.  
  22. int main(void) {
  23. 	Display* d;
  24. 	Window w;
  25. 	GC gc;
  26. 	XGCValues values;
  27. 	XEvent e;
  28. 	XFontStruct* fs, * fs16;
  29. 	char** fonts;
  30. 	int font_count;
  31. 	XFontSet fontset;
  32. 	char** missing_charsets;
  33. 	int num_missing_charsets;
  34. 	char* default_string;
  35.  
  36. 	char* msg = "Hello, World!";
  37. 	char* msg2 = "啊,世界,啊啊啊";
  38. 	int s;
  39.  
  40. 	if (setlocale(LC_ALL, "") == NULL) {
  41. 		printf("cannot set locale \n");
  42. 		exit(1);
  43. 	}
  44.  
  45. 	if (!XSupportsLocale()) {
  46. 		printf("X does not support locale %s\n", setlocale(LC_ALL, NULL));
  47. 		exit(1);
  48. 	}
  49.  
  50. 	if (XSetLocaleModifiers("") == NULL) {
  51. 		printf("Warning: cannot set locale modifiers\n");
  52. 	}
  53.  
  54.  
  55. 	d = XOpenDisplay(NULL);
  56. 	if (d == NULL) {
  57. 		fprintf(stderr, "Cannot open display\n");
  58. 		exit(1);
  59. 	}
  60.  
  61. 	fonts = XListFonts(d, "*hanzi*", 10000, &font_count);
  62. 	for (int i = 0; i < font_count; i++)
  63. 		printf("%s\n", fonts[i]);
  64. 	XFreeFontNames(fonts);
  65.  
  66. 	if ((fs16 = XLoadQueryFont(d, "hanzigb16st")) == NULL) {
  67. 		printf("Cannot load font\n");
  68. 		exit(1);
  69. 	}
  70.  
  71. 	s = DefaultScreen(d);
  72. 	w = XCreateSimpleWindow(d, RootWindow(d, s), 100, 100, 500, 500, 1,
  73. 		777215, 111111);
  74. 	printf("BlackPixel(d, s) is %d\n", (int)BlackPixel(d, s));
  75. 	printf("WhitePixel(d, s) is %d\n", (int)WhitePixel(d, s));
  76.  
  77. 	fontset = XCreateFontSet(
  78. 		d, "-*-*-*-*-*-*-16-*-*-*-*-*-*-*",
  79. 		&missing_charsets, &num_missing_charsets,
  80. 		&default_string);
  81. 	if (num_missing_charsets > 0) {
  82. 		printf("The following charsets are missing\n");
  83. 		for (int i = 0; i < num_missing_charsets; i++) {
  84. 			printf("%s \n", missing_charsets);
  85. 			printf("The string is %s \n", default_string);
  86. 			printf("of any characters from those sets\n");
  87. 		}
  88. 		XFreeStringList(missing_charsets);
  89. 	}
  90. 	XSetLineAttributes(d, gc, 5, LineSolid, CapRound, JoinRound);
  91.  
  92.  
  93. 	XSelectInput(d, w, ExposureMask | KeyPressMask);
  94. 	gc = XCreateGC(d, w, 0, &values);
  95. 	XMapWindow(d, w);
  96.  
  97. 	int y = 50;
  98. 	for (int i = 0; i < 10; i++) {
  99.  
  100. 		//XFillRectangle(d, w, DefaultGC(d, s), 20, 20, 10, 10);
  101. 		XDrawString(d, w, DefaultGC(d, s), 10, y + i * 20, msg, strlen(msg));
  102.  
  103. 		//XSetFont(d, gc, fs16->fid);
  104. 		//XDrawString16(d, w, gc, 100, y + i * 20, (XChar2b *) msg2, strlen(msg2) / 2);
  105.  
  106. 		int msg_len = strlen(msg2);
  107.  
  108. 		DrawCenteredMbString(
  109. 			d, w, fontset, gc,
  110. 			msg2,
  111. 			msg_len, 50, y + i * 20, 100, 50);
  112.  
  113. 		XFlush(d);
  114. 		sleep(1);
  115.  
  116. 	}
  117.  
  118. 	/*while(1) {
  119. 		XNextEvent(d, &e);
  120. 		if (e.type == KeyPress)
  121. 		  break;
  122. 	}*/
  123.  
  124. 	XCloseDisplay(d);
  125. 	return 0;
  126. }

Calling a C Function From Lua

Prepare So

  1. #include <math.h>
  2. #include <lua.h>
  3. #include <lauxlib.h>
  4. #include <lualib.h>
  5.  
  6. static int my_sum(lua_State *L){
  7.     int d1 = luaL_checknumber(L, 1);
  8.     int d2 = luaL_checknumber(L, 2);
  9.     lua_pushnumber(L, d1+d2);
  10.     return 1;
  11. }
  12.  
  13. static int my_info(lua_State *L){
  14.     lua_pushstring(L, "qinuu");
  15.     return 1;
  16. }
  17.  
  18. static const struct luaL_Reg test_lib[] = {
  19.     {"my_sum" , my_sum},
  20.     {"my_info" , my_info},
  21.     {NULL, NULL}
  22. };
  23.  
  24. int luaopen_test_lib(lua_State *L){
  25.     //luaL_newlib(L, test_lib); // 5.2
  26.     luaL_register(L, "test_lib",test_lib); // lua 5.1
  27.     return 1;
  28. }

Test

  1. local my_lib = require "test_lib"
  2.  
  3. print(type(test_lib))
  4.  
  5. print(test_lib.my_sum(23,17))
  6.  
  7. print(test_lib.my_info())

Speed up by ignoring std::cout

Test Code

  1. #include <iostream>
  2.  
  3. int main(int argc, char *argv[])
  4. {
  5. 	//std::cout.setstate(std::ios_base::badbit);
  6. 	for(int i = 0; i < 100; i ++) {
  7. 		for(int i = 0; i < 100; i ++) {
  8. 			;//std::cout << "" << std::endl;
  9. 		}
  10. 	}
  11. 	return 0;
  12. }

Test it without std::cout

  1. root@imx6ul7d:~/tmp# time ./t1_1 
  2.  
  3. real    0m0.041s
  4. user    0m0.020s
  5. sys     0m0.000s

Test it with std::cout, but redirect to /dev/null

  1. root@imx6ul7d:~/tmp# time ./t1_0 > /dev/null
  2.  
  3. real    0m0.096s
  4. user    0m0.030s
  5. sys     0m0.030s

Test it with std::cout, but set io state

  1. root@imx6ul7d:~/tmp# time ./t1_2
  2.  
  3. real    0m0.061s
  4. user    0m0.040s
  5. sys     0m0.000s

Profile : Linux

Example 1

Add -pg

  1. arm-linux-gnueabihf-g++ -Wall -g -pg hello.cpp -o hello -std=c++17

Test

  1. [email protected]:~# gprof -b hello 
  2. Flat profile:
  3.  
  4. Each sample counts as 0.01 seconds.
  5.   %   cumulative   self              self     total           
  6.  time   seconds   seconds    calls   s/call   s/call  name    
  7. 100.00      3.45     3.45        1     3.45     3.45  hehe()
  8.   0.00      3.45     0.00        4     0.00     0.00  std::_Optional_base<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::_M_is_engaged() const
  9. ......