Skip to main content

Posts

Showing posts from 2018

Opening huge file, comparison Editor: Vim, Emacs, Sublime-Text ...

Sometime we mistake open a huge file because we forgot the size of dump database or open wrong file. It take huge time and computer hang on. But Emacs seem no problem. I have tried many editor and Emacs seem open all not only size but whatever file extension like pdf or  zip... I am too lazy to re-test these editor and provide evident.

Docker with Geohot - From the Transistor: Xilinx on MAC

There are some cool idea from geohot in how he deal with Docker, for example, create a localhost HTTP file server for local fetch/download on the fly.

Note Angular 6+ (p3)

ngx-select-dropdown required validation Default ngx-dropdown input required not work. <ngx-select-dropdown [config] = " exerciseDropdownConfig " [options] = " exercises " [(value)] = " exercise_id " ></ngx-select-dropdown> https://github.com/optimistex/ngx-select-ex/issues/44 [(value)]="exercise_id" : exercise_id is ngModel or formControlName in reactive form ? It seem   exercise_id : [ '' , [Validators. required ]] ,   not work, exercise value selected now is an ojbect ie. {['id': 1, 'name': 'Exercise 1']}; So validation need some work around. $ sign in typescript indicate it is Observable https://stackoverflow.com/questions/37671700/angular2-style-guide-property-with-dollar-sign Create object based on interface https://stackoverflow.com/questions/13142635/how-can-i-create-an-object-based-on-an-interface-file-definition-in-typescript Interface vs Model, when to use ? different ? nterfa...

Note some architecture, technical design and decision

Read-receipt (remembering TX*:-) Skype notice that over 20 users in a room may have some different in read receipt. I believe this is a limit to assume that read-receipt working reliably. And in paid version I think Skype offer much larger number. In technical aspect, this is clever way to both notice user problem with big room (20 people and lager) and hide/reduce technical requirement on Developer side. https://dzone.com/articles/software-rebuilding-make-it-or-break-it

Note some Laravel, NGINX, NodeJS deploy

Avoid/reduce log output on Laravel Console https://stackoverflow.com/questions/49346700/laravel-disable-artisan-console-output-when-running-tests Gcloud SSH issue Jun 20 06:37:18 instance-3 sshd[12753]: Connection closed by 113.190.235.xxx port 7600 [preauth] Jun 20 06:37:19 instance-3 sshguard[1393]: Blocking 113.190.235.188:4 for >630secs: 40 danger in 4 attacks over 184 seconds (all: 40d in 1 abuses over 184s). sudo service sshguard restart USER=root ; COMMAND=/usr/sbin/service sshguard restart Jun 20 06:45:11 instance-3 sudo: pam_unix(sudo:session): session opened for user root by vandung53cc(uid=0) Jun 20 06:45:11 instance-3 sshguard[1393]: Got exit signal, flushing blocked addresses and exiting... Jun 20 06:45:11 instance-3 sudo: pam_unix(sudo:session): session closed for user root Jun 20 06:45:11 instance-3 sshguard[12902]: Started with danger threshold=40 ; minimum block=420 seconds Jun 20 06:45:15 instance-3 sshd[12909]: Connection closed by 113.190.235.188 por...

Note Docker 27-11 lumen microservices Bamboo AWS ECR

mysql: build: ./mysql volumes: - ./mysql/startup:/docker-entrypoint-initdb.d volumes_from: - volumes_data ports: - "3309:3306" environment: MYSQL_ROOT_PASSWORD: 1234 However to run php artisan from workspace container I need .env to specify port 3306: DB_HOST=mysql DB_DATABASE=local_a DB_USERNAME=root DB_PASSWORD=1234 DB_PORT=3306 I guess this is because I am connecting container to container, however maybe this will help someone. Docker https://github.com/FabrizioCafolla/microservice-lumen/wiki https://www.poweredlocal.com.au/ php redis osx => may be manual build/install https://stackoverflow.com/questions/50456780/run-mysql-on-port-3307-using-docker-compose https://github.com/guillaumebriday/laravel-blog/blob/master/docker-compose.yml https://medium.com/@shakyShane/laravel-docker-part-1-setup-for-development-e3daaefaf3c Authen header bearer http://self-issued.info/docs/draft-ietf-oauth-v2-bearer.html#authz-header Ubuntu VPS work without header Auth...

How exp important in SE: productivity, exp, creativity

1. How to ask the right questions so that you solve the right problem 2. How to work with complex, homegrown systems in someone else's code base 3. How to connect the right data to a system made of several moving parts 4. How to estimate accurately, especially when it comes to dependencies on other people 5. How to learn new technologies and apply them correctly 6. How to be disciplined and create code that you can maintain years down the road Random moments :)

S3 auto build Angular sample script

$ cat ./web-app/buildspec.yml version: 0.1 environment_variables:     plaintext:         S3_BUCKET: "staging.yoursite.com" phases:     install:         commands:             - echo Installing source NPM dependencies...             - npm install             - npm install -g @angular/cli     build:         commands:             - echo Build started on `date`             - ng build     post_build:          commands:             - aws s3 cp dist s3://${S3_BUCKET} --recursive             - echo Build completed on `date` artifacts:     files:         - '**/*'     base-directory: 'dist*'

Note React 2

Debugging https://medium.com/@baphemot/intro-to-debugging-reactjs-applications-67cf7a50b3dd Sync/update input from URL params https://stackoverflow.com/questions/36596996/how-to-sync-redux-state-and-url-query-params https://stackoverflow.com/questions/35352638/how-to-get-parameter-value-from-query-string/48256676#48256676 https://developmentarc.gitbooks.io/react-indepth/content/life_cycle/birth/post_mount_with_component_did_mount.html https://tylermcginnis.com/react-router-url-parameters/ Structure project https://medium.freecodecamp.org/how-to-structure-your-project-and-manage-static-resources-in-react-native-6f4cfc947d92 Deploy app, pm2 (again!) https://hackernoon.com/start-to-finish-deploying-a-react-app-on-digitalocean-bcfae9e6d01b This also say something y we should use proxy (ie. NGINX) to reduce Web server (PM2, Apache) task. React server side rendering It seem React have something that need run on server side, so it not alway hosted on S3 as Angular build ...

Note Angular 6+ (p2)

isUndefinedOrNull() angular.isUndefinedOrNull = function(val) {     return angular.isUndefined(val) || val === null } https://blog.angularindepth.com/everything-you-need-to-know-about-the-expressionchangedafterithasbeencheckederror-error-e3fd9ce7dbb4 https://stackoverflow.com/questions/16017699/how-can-i-check-which-version-of-angular-im-using https://github.com/eduardoboucas/include-media https://github.com/eduardoboucas/include-media https://angular.io/guide/reactive-forms https://stackoverflow.com/questions/679915/how-do-i-test-for-an-empty-javascript-object Ext.Object.isEmpty({}); // true // not RxJS Common ng6+ err https://stackoverflow.com/questions/45467881/expressionchangedafterithasbeencheckederror-expression-has-changed-after-it-was https://stackoverflow.com/questions/44614108/when-does-angular-trigger-ngaftercontentchecked many hook here :) remember WP hookr ? FormControlName vs NgModel https://stackoverflow.com/questions/43669773/angul...

Notes CSS part 2

https://github.com/FrontendMasters/front-end-handbook-2018/blob/master/learning/html-css.md Use calc() right https://codepen.io/nicolasjengler/post/don-t-misuse-the-calc-css-function What is flexbox ? https://flexbox.io/ Table to Div from Hell to Hell https://www.smashingmagazine.com/2009/04/from-table-hell-to-div-hell/ Do some research on how to write HTML, CSS faster, more productive and less maintenance cost. https://www.quora.com/How-can-I-code-CSS-faster Agreed that wrong, improper HTML (often from customer, Frontend team) that lead to extra work to reinforcement,working around, tricky or hacky way of coding. And although agreed that most of CSS by the time is not needed but rarely we remove this because of aware that something removed may be used somewhere else. Especial with handover project. React require we write/rewrite everything, so it may be very effective in this case to tackle problems. Calc rounding number https://stackoverflow.com/questions/25938915...

Note AWS 3 GP2 vs IO1, create instance use CLI, change volume zone

https://docs.aws.amazon.com/cli/latest/reference/opsworks/create-instance.html Change volume region for attach/mount https://serverfault.com/questions/869710/is-it-possible-to-change-the-ebs-volume-to-different-availability-zones GP2 vs IO1 (General Purpose vs I Optimized) AWS EBS SSD https://www.fittedcloud.com/blog/is-it-possible-to-use-ebs-gp2-instead-of-io1-achieve-same-performance-and-save-50/ I can not access new Instance by normal SSH. After copy guide from control panel as bellow I can login. Latter I realize that I have used wrong user ('ec2') instead of ubuntu. (old but often miss this point). From guide I see that there are public DNS, then I can use this to connect. Ping often disabled by default on EC2 instance. To access your instance: Open an SSH client. (find out how to connect using PuTTY) Locate your private key file (osx_key_one.pem). The wizard automatically detects the key you used to launch the instance. Your key must not be publicly viewabl...

https://comma.ai/jobs

Who do we look for? Competitors People who have done well at math competitions(USAMO, IMO, PUTNAM), competition programming(ACM, USACO, codejam, topcoder), science fairs(ISEF, STS), or capture the flag(DEFCON, secuinside, GITS). Those competitions don't just select for ability, they also select for quickness. We are in a very competitive space. Contributors People who have contributed value to open source projects. Show us your github. Got stars? Code is never measured in quantity, but rather quality. We value those who can do more with less code; software engineering doesn't have an external selection pressure for low part count and cost like EE and ME, but you pay massive costs down the line in debugging and upkeep. Architects People who can design good APIs and source layouts on the first try. This is crucial to working in teams and scaling. Before you do work, you should be able to explain to a contractor what you want done. ME has a great divide between de...

Note some ideas: Game use user voice, hanging chair for disabled person.

New sample for previous idea: "Hectooor!" calling out voice game. Many many meme and epic culture like "Houston, we've had a problem", " mày mang dạ về đây", "da sheng cau" trong vạn vạn ko ngờ tới ... Hanging chair for disabled: I don't know why this idea come out, but in my many dream that I can easy moving around without leg. Imagine you are in water then you can easily moving around with your hand. For example imagine you are in a shallow pool, you can easily moving around with your hand only if there are some hanging rope or handle for you. So we can try to make some concept wheel or wheeless chair for disabled pp. Certainly we have to study many current product (mostly china product sold in VN because it affordable...) I will draw and update more specific design detail latter. When you have to shoot, shoot don't talk.

CURL send request SOAP with XML file input data

http://dasunhegoda.com/make-soap-request-command-line-curl/596/ cat XML/curl-format.txt  time_namelookup:  %{time_namelookup}\n        time_connect:  %{time_connect}\n     time_appconnect:  %{time_appconnect}\n    time_pretransfer:  %{time_pretransfer}\n       time_redirect:  %{time_redirect}\n  time_starttransfer:  %{time_starttransfer}\n                     ----------\n          time_total:  %{time_total}\n  curl --header "Content-Type: text/xml;charset=UTF-8" --header "SOAPAction: NewXXXRequest" --data @xml1.xml -w "@curl-format.txt" http://dev.server.com/yourDataCatcher.php

Ý tưởng server VPS giá rẻ ở Việt Nam

Ở các nước nghèo thì nên tiết kiệm chi phí, để dành nguồn lực tối ưu cho các lãnh vực hiệu quả nhất. Server VPS dùng Raspie hoặc tương đương, máy tính cũ hoặc thừa ít dùng.   IP tĩnh nếu ko có hoặc đắt thì viết 1 script tự động sync ip động lên cloud để báo thay đổi, Về cơ bản là dùng 1 cronjob check IP internet nểu đổi thì update rồi sync lên Dropbox, GDrive hay tương đương.   Tên miền thì chưa rõ ngoài tên miền free ra còn cách nào ko.   Hệ thống điện, làm mát cũng quan trọng nhất là mùa hè VN.   Bụi bặm khiến việc bảo trì và tuồi thọ server tốn kém.   Đường mạng thiếu ổn định. Nên tìm 1 giải pháp 2 đường mạng hoặc phát sim 3g lúc khẩn cấp.   Tự động hóa nhờ 1 số opensource + openhardware.   Sercurity InfoSec: Cái này kiểu outofthebox nên cần con người đào tạo, nghiên cứu chứ khó "mua" được. ...

Cài đặt Wifi IP Camera VNTIS GLOBAL

Bài này mình note lại cách cài đặt Wifi cho Camera IP hiệu GLOBAL VNTIS. Do khá bận nên mình chỉ viết tóm tắt, chi tiết mình sẽ update sau. 1. Cài app (ứng dụng) camera của hãng GLOBAL VNTIS https://play.google.com/store/apps/details?id=com.vntis.p2pclient&hl=en 2. Cài Wifi cho camera Các bước: (Làm theo hướng dẫn từ ứng dụng của hãng): [1] Bật ứng dụng camera, chọn thêm camera (nút + trên phải) [2] Chọn |Configure WiFi and add device| (mình update tiếng Việt sau). Đây là lựa chọn thứ hai, bên dưới nút Thêm device (camera). Thêm device là thêm cam để theo dõi, còn nút |Config/cấu hình WiFi| chính là nút đến màn cài WiFi cho cam. [3] Cắm nguồn để bật Camera lên. Để camera trên bàn hay ở nơi cố định tiện thao tác. Trên điện thoại màn hình ứng dụng GLOBAL thì chọn Next. [4] Nếu cấu hình lại WiFi hoặc không chắc cam đã được reset chưa thì bạn reset lại cam. Ở bên dưới đáy cam có lỗ nhỏ để reset. Lấy que tăm nhỏ cắm vô giữ tầm 15s là được. Cam có báo chuông để biết r...

Một số phần mềm Remote Desktop miễn phí và tính phí

Bài này mình note lại một số vấn đề mình hay gặp khi làm remote từ xa, chủ yểu ở nhà lên cty. Các phần mềm, tool đã dùng cùng ưu/nhược điểm để so sánh. Ngoài ra mình cũng note thêm về giá cả, thanh toán và một số thiết bị phần cứng hỗ trợ khác. 1. Phần mềm TeamViewer dùng nhiều nhất nhưng thi thoảng bị bắt lỗi dùng thương mại (dùng kiểu commercial) và bị giới hạn nhiều thứ như chỉ remote được 5p. Dù khi bị giới hạn 5p nhưng điện thoại thì vẫn OK. Tức là dùng app TeamViewer để truy cập máy tính thì vẫn không bị bắt lỗi dùng thương mại trong khi máy tính khác thì đang bị bắt lỗi. Phiên 5p cho một lần remote, chờ vài phút sau mới làm tiếp được. Hầu như không làm được gì trong 5p. Tuy nhiên một số trường hợp vẫn có ý nghĩa, méo mó có hơn không. Ví dụ cài phần mềm remote khác nó đòi mã xác thực thì phải vô máy cty để copy rồi gửi lại. TeamViewer trên Linux khá nặng và tốn CPU/RAM, máy rất nóng. Xem process thì nó chạy Wine kiểu giả lập chạy EXE trên Linux chứ ko phải Native App. - R...

Note Laravel query, Angular 2 ...

https://laravel-news.com/eloquent-tips-tricks     /**      * @param Request $request      * @param integer $bankId      * @param datetime $from      * @return \Illuminate\Http\JsonResponse      */     public function getBankFilesUploadedFromMonth(Request $request, $bankId = null)     {         $fromMonth = $request->get('fromMonth', '01');         $fromYear  = $request->get('fromYear', date('Y'));         $account = $request->get('user');         try {             if (!$account->isAdmin())                 $bank = $account->bank;             else                 $bank = $this->bankRepository->find($bankId, true);   ...

Laravel Job queue Supervisord and beanstalkd

   Active: inactive (dead) ubuntu@ip-172-31-29-15:/var/www/risk_advisor_dev/risk_advisor/API$ sudo service supervisor status ● supervisor.service - Supervisor process control system for UNIX    Loaded: loaded (/lib/systemd/system/supervisor.service; enabled; vendor preset: enabled)    Active: active (running) since Wed 2018-09-05 02:44:50 UTC; 49min ago      Docs: http://supervisord.org   Process: 19220 ExecStop=/usr/bin/supervisorctl $OPTIONS shutdown (code=exited, status=0/SUCCESS)  Main PID: 19223 (supervisord)     Tasks: 4    Memory: 111.6M       CPU: 1min 47.037s    CGroup: /system.slice/supervisor.service            ├─19223 /usr/bin/python /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf            ├─19229 php /var/www/risk_advisor_dev/risk_advisor/API/artisan queue:listen --timeout=3000   ...

CMD 3

TASKKILL /F /IM httpd.exe /T C:\WINDOWS\system32>netstat -a -b |findstr /R /C:"80" https://stackoverflow.com/questions/76074/how-can-i-delete-a-service-in-windows SC QUERY state= all >"C:\Service List.txt" SC STOP shortservicename SC DELETE shortservicename SC QUERY state= all | FIND "_NAME"

XAMPP suck

<VirtualHost *:8080>    ServerAdmin ahihi@gmail.com    DocumentRoot "C:\Server\www\Org\APIOrg\public"    ServerName organi.uat.test.co    ErrorLog "logs/or.dev-error.log"    CustomLog "logs/or.dev-access.log" common </VirtualHost> <Directory "C:\Server\www\Org\APIOrg\public">         Options Indexes FollowSymLinks MultiViews         AllowOverride all         Order Deny,Allow         Allow from all         Require all granted </Directory> <VirtualHost *:8080> #   ServerAdmin ahihi@gmail.com    DocumentRoot "C:\Server\www\Org\SVN\Adminphase2"    ServerName admin.organi.uat.test.co #   ErrorLog "logs/or.dev-error.log" #   CustomLog "logs/or.dev-access.log" common    <Directory "C:\Server\www\Org\SVN\Adminphase2">         ...

Yith Woocommerce Subscription - Cancel the subscription billing in Stripe when customer doesn't finish/fail to pay the first payment

https://docs.yithemes.com/yith-woocommerce-subscription/premium-settings/suspension/ There are many defect card to test each response status. One of these is declined (before we get to thank you page). 4000000000009995 Charge is declined with a card_declined code. The decline_code attribute is insufficient_funds. If you have time, try these status, it may be useful and reduce confuse each time you touch these test. https://stripe.com/docs/testing Use Simply Show Hooks for faster find hook (than grep ?). It shine when we have to narrow down search scope (ie. error page).

Some Java, J2ME Class, functions

Complex String usage. https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#field_summary String public String(char[] value,       int offset,       int count) Allocates a new String that contains characters from a subarray of the character array argument. The offset argument is the index of the first character of the subarray and the count argument specifies the length of the subarray. The contents of the subarray are copied; subsequent modification of the character array does not affect the newly created string. Parameters: value - Array that is the source of characters offset - The initial offset count - The length Throws: IndexOutOfBoundsException - If the offset and count arguments index characters outside the bounds of the value array "java is always pass-by-value"  https://softwareengineering.stackexchange.com/questions/286008/parameters-are-passed-by-value-but-editing-them-will-edit-the-actual-object-li/286013 The...