Skip to main content

Posts

Showing posts from 2020

Notes on old CI 2

 https://stackoverflow.com/questions/41789659/only-variables-should-be-assigned-by-reference-with-function From DotENV $quote        = $value[0];             $regexPattern = sprintf(                     '/^                     %1$s          # match a quote at the start of the value                     (             # capturing sub-pattern used                                   (?:          # we do not need to capture this                                    [^%1$s\\\\] # any character other than a quote or backslash     ...

Notes on daily bash Dec-07 2020

 https://unix.stackexchange.com/questions/42898/find-any-lines-exceeding-a-certain-length Get lines exceeding a certain length. grep '.\{80\}' file perl -nle 'print if length$_>79' file awk 'length>79' file sed -n '/.\{80\}/p' file Get the max length line wc -L brake_input.model.dat Get nth line: sed 'NUMq;d' file If you have NUM in a variable, you will want to use double quotes instead of single: sed "${NUM}q;d" file https://stackoverflow.com/questions/6022384/bash-tool-to-get-nth-line-from-a-file Assuming you need lines 20 to 40, sed -n '20,40p;41q' file_name => not work as expected or awk 'FNR>=20 && FNR<=40' file_name This one work: sed -n -e '10,100p' input.txt > output.txt https://gist.github.com/simofacc/061aaf189a559a0817bf https://stackoverflow.com/questions/13294341/create-slug-to-include-id-and-title-when-insert-record-php-mysql CREATE TRIGGER trigger_name BEFORE INSERT ON tab...

Compare diff tools

Beyond compare seem better than Meld but it not free. Can we use git history (merge, pull request or history change) ? This may possible but suck with big file. => Will try cut file and update result later.  https://github.com/unhammer/diff-large-files => This seem not work, only show normal diff. https://www.tecmint.com/best-linux-file-diff-tools-comparison/ vimdiff seem cool. http://kdiff3.sourceforge.net/ https://www.scootersoftware.com/download.php https://en.wikipedia.org/wiki/PowerShell I'd been driving a bunch of managing changes, and then I originally took the UNIX tools and made them available on Windows, and then it just didn't work. Right? Because there's a core architectural difference between Windows and Linux. On Linux, everything's an ASCII text file, so anything that can manipulate that is a managing tool. AWK, grep, sed? Happy days! I brought those tools available on Windows, and then they didn't help manage Windows because in Windows, everyth...

Lucky Orange customer behaviors recording

 Lucky Orange is a cool tool for tracking customer behaviors. One of the cool use case is to debug website bugs. Sometime tracing user state that lead to bug is very difficult. Tracking user devices and behaviors before bug occur is priceless. While clean my small Ubuntu Vbox, I found that journal log too fat (4GB) so I clean it. https://unix.stackexchange.com/questions/139513/how-to-clear-journalctl Retain only the past two days: journalctl --vacuum-time=2d Retain only the past 500 MB: journalctl --vacuum-size=500M

grep cool new technique with special character

grep suck with some special characters like this "1-Piston Calipers;" grep -Fn => -F make input search pattern as fixed string. grep -Fn --text treat input file as text, so avoid binary matches result. Example result: 1-Piston Calipers; Oversized�Caliper... https://stackoverflow.com/questions/23512852/grep-binary-file-matches-how-to-get-normal-grep-output https://stackoverflow.com/questions/12387685/grep-for-special-characters-in-unix https://stackoverflow.com/questions/32564046/php-detect-the-character-encoding-of-the-file-system

MySQL Cross Table Update

 https://electrictoolbox.com/cross-table-update/ MySQL UPDATE cross table Cross Table Update with MySQL Using MySQL version 4.0 or higher you can update a table by joining two or more tables together; note that the examples shown in this article are not possible with MySQL 3.23 or earlier. By joining two tables together you can update one table based on fields in associated records in another table. Let's say for example you have a product table which stores information about products and a productPrice table which has pricing information and you want to update the prices based on when the product was created (in the examples below you want to discount all your older stuff to 80% of the current price). In MySQL you can do this in one of two ways. The first is do do a join using commas, like so: UPDATE product p, productPrice pp SET pp.price = pp.price * 0.8 WHERE p.productId = pp.productId AND p.dateCreated < '2004-01-01' The second way is to use inner join syntax as sho...

Damn missing Bit Torrent

 https://webtorrent.io/intro < form > < label for = "torrentId" > Download from a magnet link: </ label > < input name = "torrentId" , placeholder = "magnet:" value = "magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel.torrent" > < button type = "submit" > Download </ button > </ form > https://www.theverge.com/2020/7/31/21348963/google-chrome-os-windows-apps-chromebooks-features-i...

Cool information about MySQL Merge - What are the advantages and disadvantages of MERGE tables?

 http://www.mysqlab.net/knowledge/kb/detail/topic/merge/id/5123 MySQL知识库 :: merge What are the advantages and disadvantages of MERGE tables? Discussion MERGE tables can help you solve the following problems: Easily manage a set of log tables. For example, you can put data from different months into separate tables, compress some of them with myisampack, and then create a MERGE table to use them as one. Obtain more speed. You can split a big read-only table based on some criteria, and then put individual tables on different disks. A MERGE table on this could be much faster than using the big table. You can also use a RAID table to get the same kind of benefits. Do more efficient searches. If you know exactly what you are looking for, you can search in just one of the split tables for some queries and use a MERGE table for others. You can even have many different MERGE tables that use overlapping sets of tables. Do more efficient repairs. It's easier to repair the individual tables t...

Working Effectively with Legacy Codes - notes

 Robert C. Martin Series This series is directed at software developers, team-leaders, business analysts, and managers who want to increase their skills and proficiency to the level of a Master Craftsman. The series contains books that guide software professionals in the principles, patterns, and practices of programming, software project management, requirements gathering, design, analysis, testing, and others. https://stackoverflow.com/questions/748503/how-do-you-introduce-unit-testing-into-a-large-legacy-c-c-codebase https://docs.microsoft.com/en-us/archive/msdn-magazine/2009/december/generation-test-automated-unit-tests-for-legacy-code-with-pex https://www.weeklydevtips.com/episodes/015 https://dzone.com/articles/introduction-test-driven But using Test-Driven Development for legacy code is a little different from using TDD in a green-fields context. The general approach is identical: Write a test to reproduce the error (test bar red) Write code to fix the error (test bar green)...

Working with Legacy code - Lag Time

 Lag Time Changes often take a long time for another very common reason: lag time. Lag time is the amount of time that passes between a change that you make and the moment that you get real feedback about the change. At the time of this writing, the Mars rover Spirit is crawling across the surface of Mars taking pictures. It takes about seven minutes for signals to get from Earth to Mars. Luckily, Spirit has some onboard guidance software that helps it move around on its own. Imagine what it would be like to drive it manually from Earth. You operate the controls and find out 14 minutes later how far the rover moved. Then you decide what you want to do next, do it, and wait another 14 minutes to find out what happened. It seems ridiculously inefficient, right? Yet, when you think about it, that is exactly the way most of us work right now when we develop software. We make some changes, start a build, and then find out what happened later. Unfortunately, we don’t have software that k...

Notes on weird Wifi Home network with multiple routers

 https://www.net.princeton.edu/software/dhcp_probe/ http://odhcploc.sourceforge.net/ Mobile Android Xiaomi Redmi note 7 can not access internet. It can ping local LAN IP but it detect wrong gateway. Since 192.168.1.1 web access lead to wrong router (this one already disable DHCP). https://sites.google.com/site/quanghoangls/thong-bao/modem-router/cau-hinh-router-wifi-chay-ngang-hang-voi-modem Yee => It turned out that the 2nd Wifi Router setup incorrectly when it set LAN IP = 192.168.1.1 that same as Internet Modem.

Notes on book Working Effectively with Legacy Code p1

From page 310. Hyperaware Editing    If it isn’t out by the time this book is released, I suspect that someone will soon develop an IDE that allows you to specify a set of tests that will run at every keystroke. It would be an incredible way of closing the feedback loop. It has to happen. It just seems inevitable. There are already IDEs that check syntax on each keystroke and change the color of code when there are errors. Edit-triggered testing is the next step.     Tests foster hyperaware editing. Pair programming does also. Does hyperaware-editing sound exhausting? Well, too much of anything is exhausting. The key thing is that it isn’t frustrating. Hyperaware editing is a flow state, a state in which you can just shut out the world and work sensitively with the code. It can actually be very refreshing. Personally, I get far more tired when I’m not getting any feedback. At that point, I get scared that I’m breaking the code without knowing it. I’m struggling to ma...

Why git push --force after rebase

https://stackoverflow.com/questions/8939977/git-push-rejected-after-feature-branch-rebase This post explain why we have to git push --force after rebase, otherwise it show error/warning message. I'm too lazy to find it out, but this explain seem quite straightforward. The problem is that git push assumes that remote branch can be fast-forwarded to your local branch, that is that all the difference between local and remote branches is in local having some new commits at the end like that: Z--X--R         <- origin/some-branch (can be fast-forwarded to Y commit)        \                 T--Y    <- some-branch When you perform git rebase commits D and E are applied to new base and new commits are created. That means after rebase you have something like that: A--B--C------F--G--D'--E'   <- feature-branch        \           D...

Why is only one device being allowed on the internet through a router

https://superuser.com/questions/691371/why-is-only-one-device-being-allowed-on-the-internet-through-my-asus-router/691389 This can happen when your Wi-Fi "router" is actually just bridging, and your broadband modem latches onto the first LAN-side MAC address it sees after it boots. DOCSIS-compliant cable modems are especially likely to do this to you. The solution is to put your Wi-Fi router back into NAT gateway mode and make sure your Wi-Fi router's WAN port (not its LAN port) is the only thing connected to the LAN side of the cable modem. Then fully power down the cable modem and then boot it back up. That the router's WAN MAC address will be the one the cable modem latches onto, because no other machine's MAC address will be visible to the cable modem. Note: If your cable modem includes telephone gateway functionality (VoIP, "digital voice", eMTA, etc.), it may have a built-in battery backup, so when you unplug the cable modem, be sure to look to see...

Hồ Ngọc Đức - những đóng góp cho từ điển tiếng Việt và Âm lịch

http://www.informatik.uni-leipzig.de/~duc/ Tôi thấy làm từ điển khá nhàm chán và tốn công sức. Làm công thức tính lịch âm (Lunar Calendar) cũng không có mấy thú vị. Tuy nhiên cái sức ảnh hưởng hay giá trị sử dụng của nó cực kỳ lớn với cộng đồng người Việt cỡ hơn 100tr người. Bài này tôi note lại công sức đóng góp của Hồ Ngọc Đức (quê Yên Bái ?). Theo thông tin trang nhà thì bác này trước du học đông Đức ĐH Leipzig thì phải. Sau học cả Berkeley, CA, Leed UK,  Nói thêm về từ điển, tôi thấy nhiều cuốn từ điển trước kia (Anh-Việt, Việt-Anh, Trung-Việt...) có nội dung rất hay và tính chính xác cao. Không như những từ điển ngày này, một điều khá khó chịu khi mà thế hệ sau phải dùng những công cụ, kết quả dịch khô khan, tối nghĩa - a deteriorate of value.  https://github.com/ThienMD/lich-van-nien-flutter http://www.informatik.uni-leipzig.de/~duc/amlich/vncal_en.html Write alternative one. http://cnchanoi.com.vn/

Notes on Shopify

Limit per IP address & users unable to add products in cart https://community.shopify.com/c/Shopify-Discussion/Limit-per-IP-address-users-unable-to-add-products-in-cart/td-p/346851 Unfortunately, in the last week Shopify’s support team wasn’t helpful with problems we are experiencing on our webshop so I’m wondering if anyone had similar issues. Our website is running on two platforms: Shopify + CMS platform we use for landing pages, home page etc.  10 days ago we noticed that some users are experiencing problems with ‘add to cart’ button - if they try to add a product, their Shopify cart in a slider is blank and contains no products. If they would click on the checkout button, Shopify’s page would show error message: too many attempts After several days and 2 completely misleading answers by Shopify, our developers realised that the problem is as follows: - Shopify has a server limit of x changes of the cart within x minutes, per customer - That way Shopify probably wants to pr...