Posts

How to Internationalizing your Flutter apps ?

Image
First Reading: https://flutter.dev/docs/development/accessibility-and-localization/internationalization Steps: 1. add flutter_localizations dependencies into pubspec.yaml dependencies : flutter : sdk : flutter flutter_localizations : sdk : flutter 2. add localizationsDelegates and supportedLocales into MaterialApp Applocalizations.delegate is your app-specific localization delegate. will be introduced in next step. Widget build ( BuildContext context) { return MaterialApp ( localizationsDelegates: [ AppLocalizations .delegate, GlobalMaterialLocalizations .delegate, GlobalWidgetsLocalizations .delegate, GlobalCupertinoLocalizations .delegate, ], supportedLocales: [ const Locale . fromSubtags (languageCode: 'zh' ), // generic Chinese 'zh' const Locale . fromSubtags ( languageCode: 'zh' , scriptCode: 'Hans' ), // generic simplified Chinese 'z

How to measure the maximum throughput (TPS - Transactions per Second) that a single website instance(host) can handle via curl tool ?

Image
tps.py, a python script using curl to measure the time per transaction requested to your website curl --connect-timeout 10 --max-time 10 -o /dev/null -s -w "%{http_code},%{size_download},%{time_appconnect},%{time_connect},%{time_namelookup},%{time_pretransfer},%{time_starttransfer},%{time_total}" -k #!/usr/bin/python #-*- coding: UTF-8 -*- import commands import getopt import os import re import sys import thread import threading import time def help(code):     print 'tps.py -A "useragent" -C "cookies" -H "header" -P "period" -T "tps" -U "url" -O "outputdir"'     print 'examples:'     print 'tps.py -U https://www.amazon.com -T 20 -P PT5M'     print 'tps.py -U https://www.amazon.com -T 20 -P PT1H'     sys.exit(code) def check_args(a, c, h, p, t, u, o):     if u == '':         print 'no URL specified!'         help(2)     if t == &#

Python : How to run a function "foo" per second and last a few minutes or hours

Scenario I tried to run a function "foo" every second. I have to do this for a few minutes (say 5). The function foo () sends 100 HTTP requests (including JSON objects) to the server and prints the JSON response. In short, I have to issue 100 HTTP requests per second for 5 minutes. Using threading.Timer #!/usr/bin/python import time import thread import threading def foo(): print time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())), threading.active_count() #5 minutes = 5 * 60 = 300 seconds for x in range(0, 300): t = threading.Timer(x + 1, foo) t.start() Expected output function foo was executed per second and last about 5 minutes 2020-05-14 00:54:49 301 2020-05-14 00:54:50 300 2020-05-14 00:54:51 299 2020-05-14 00:54:52 298 2020-05-14 00:54:53 297 2020-05-14 00:54:54 296 2020-05-14 00:54:55 295 ....... 2020-05-14 00:59:44 6 2020-05-14 00:59:45 5 2020-05-14 00:59:46 4 2020-05-14 00:59:47 3 2020-05-14 00:59:48 2

How to kill a bunch of processes which executed with almost same command ?

Scenario Sometimes we need to manually terminate the process. If not killing too many processes, it is easy to find the pid and kill it. But what if there are a bunch of processes that need to be terminated? Today I encountered such a problem, started a lot of python process, but the result can not stop. gkill Solution add below function to your bash profile, then source the profile function gkill() { ps -ef | grep ${1} | grep -v grep | awk '{print $2}' | xargs --no-run-if-empty kill -9 } Then you can kill all processes that matched your serach pattern via gkill command. gkill <search content> Extended knowledge The commands related to the termination process are: ps: report a snapshot of the current process kill: send a signal to a process killall: kill process by name pkill: View or issue process signals based on name and other attributes skill: send a signal or report the process status xkill: destroy a client program according to X resources xargs

Recommend GC log analyzer tool : GCPlot & GCeasy

Image
GCPlot Install Docker Installation You can run GCPlot in a Docker container. In order to run GCPlot as-is without additional configuration, run next command: docker run -d -p 8080:80 gcplot/gcplot After that eventually the platform will be accessible from your host machine at http://127.0.0.1:8080 address. Upload GC log JVM arguments -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+PrintGCCause -XX:+PrintHeapAtGC -XX:+PrintAdaptiveSizePolicy -XX:+UnlockDiagnosticVMOptions -XX:+G1SummarizeRSetStats -XX:G1SummarizeRSetStatsPeriod=1 -Xloggc:/var/output/logs/garbagecollector.log -XX:+UseG1GC Analysis Groups Universal GC Log Analyzer https://gceasy.io/ It is more powerful than GCPlot, but you have to upload you GC logs to their backend and pay to see the analysis report. GCPlot is free and open source Fork from github https://it.gcplot.com/

English Language : 20 ways to give advice

MODALS You have to ... You'd better ... You should ... You ought to ... You could ... CONDITIONALS If I were you, I'd ... If I were in your shoes, I'd ... If you want my advise, I think ... If you really want to know, I'd ... If I were in your position, I'd ... FORMAL VERBS I suggest (that) you ... I recommend (that) you ... I urge you ... I would advise you to ... CASUAL You're gonna wanna ... You might wanna consider You should probably consider You should maybe think about ... Have you thought about ... ? What you yought do is ... ?

English Language : Adverbs of Intensity

Image
OMG SO INTENSE completely totally thoroughly absolutely perfectly extremely Utterly Kind of intense fairly rather somewhat moderately considerably nearly kind of sort of noticeable pretty intense awfully pretty really so very mostly quite ehh... a little a bit slightly Common combinations perfectly sort of bland a little hungry absolutely certain pretty sure quite good nearly exausted mostly finished noticeably different