Skip to main content

Posts

Showing posts from May, 2018

Some WPEngine special configuration/behavior

https://yoursite.wpengine.com/?hauth_done=Facebook https://yoursite.staging.wpengine.com/?hauth_done=Facebook https://yoursite.wpengine.com/index.ph.p....?hauth_done=Facebook (long URI) http://miled.github.io/wordpress-social-login/troubleshooting.html https://wordpress.org/support/topic/500-internal-server-error-when-redirecting/

Karaoke Kara devices and apps

I don't like Karaoke, I prefer real music like Stratocaster or something like this. But this kind 'dream of music' so expensive in VN. I see that there are some Karaoke app provider like Kara. And I think it damn expensive for a device that combine of a PC and a monitor (touch screen). For my first (and fast) research Kara M10 cost about 6.5m VND for monitor, 11.5m VND for PC. I think this toy can be made much cheaper with something like arduino or raspi for PC, touch screen cost seem no way to reduce ? I don't know much about this but some laptop has touch screen and it is not so expensive. I have an occasion interview in Kara office and as many other 'Made in Vietnam' Electronic commodity, it is 'China inside'. It is a box like a small PC running Linux and opensource (moded) software I think. China now is hardware manufacturer of all the thing on Earth. So it is not surprise. I hate many scam and super bad quality, bad service of so many product i

Understanding Facebook IDs

https://www.nayuki.io/page/understanding-facebook-ids On Facebook, an identifier (FBID) is assigned to most pieces of content. The identifier is a simple positive integer like 12345. You can use the FBID to cite a piece of content precisely and concisely using the URL fb.com/<fbid>. Explained below, a publicly visible FBID is available for many types of content, though not all types. These identifiers can be used (and abused) in interesting ways. Examples Here are some URLs of various content on Facebook. The FBID is indicated in bold: https://www.facebook.com/profile.php?id=4 https://www.facebook.com/pages/doorsopenTO/361063578336 https://www.facebook.com/photo.php?fbid=10151052362543337&set=a.402126878336.167300.361063578336 https://www.facebook.com/doorsopenTO/posts/10150868476418337 Scope For these top-level types, each item has an FBID: Person (a.k.a. profile, user, timeline) Page Event Group For these types that are attached to a top-level item, each

MF Refactoring notes

Refactoring của Martin Fowler đã ra bản 2 rồi nhưng bản 1 còn chưa đọc xong. https://refactoring.com/catalog/ Có nhiều kỹ thuật khá cool về kỹ thuật coding, refactor code, OOP ... Nhiều kỹ thuật bên OOP tôi ko biết nhưng qua các ví dụ refactor thì học thêm được 1 cách tiếp cận nó. VD như nhiều pattern nổi tiếng như Observer Pattern, Replace Type Code with State/Strategy ... khá hay. Trong 1 bài về nghiên cứu về Wordpress mình thấy Observer Pattern chỉ là hữu danh vô thực, rất ít thư viện, app thực tế dùng observer pattern. http://cheatortrick.blogspot.com/2018/02/design-pattern-kien-truc-wordpress-so.html Consolidate Conditional Expression Consolidate Duplicate Conditional Fragments semantics preserving change => Gtrans "ngữ nghĩa bảo tồn thay đổi" Design: Translations of design verb bày ra một kiểu design dành riêng cho design dự định design, purpose, predetermine, provide quyết định cho design sáng kiến design sắp đặt layout, dispose,

Lighthouse automatic run audit and report result for a web site

Lighthouse is a SEO, performance audit tool by Google Chrome. It provide many report about performance, SEO with suggestion to improve. This guide I will try to write some bash script and/or NodeJS module to automated the process. This guide include many tools: ScreemingFrog (SEO tool, this require fee or you can cr*k :), search free key ) Lighthouse   and here  https://developers.google.com/web/tools/lighthouse / Lighthouse viewer  https://googlechrome.github.io/lighthouse/viewer2x/ Git-Bash (some unix tool on fucking Windows) Python3 (if you use Windows then find yourself how to install it). NodeJS: Lighthouse and many tool is based on (or install required NodeJS) Script to get only performance Optimized images report from a URL: #!/bin/bash FILES=./LH_json/* for f in $FILES do   report_length=$(cat $f |  python3 -c "import sys, json; print(json.load(sys.stdin)['audits']['uses-optimized-images'])" | wc -m);   report="$(cat $f | python3

Entropy and arrow of time PHP uniqid()

I have experienced a cool critical situation about lost live data. Lost live data is a common problems and myth. Outline: Bash ls order by time ls default order by name ls order by both time and name (fallback) Simulate time when create file Simulate time when move file (move is faster and may be timestamp duplicate) Bash programming variable as output of a command use cat /dev/urandom to generate random string, number ... /dev/urandom seem only return number when run inside bash shell (Windows Git-Bash) ... Our live server has been lost about 7000 images. Exactly its has been renamed, the original image file content is keep. But it's filename has been changed and inside Database it's not reflected yet. Let make it simple: In DB a record look like: ID   Image_URL ... 1     image_product_001.jpg In real image web data folder: name      vuETHeuteuehteecCHUE And the function that lead to disaster look like: loop through product_image (after 1-May for example

WP CLI 2

https://guides.wp-bullet.com/using-wp-cli-for-batch-updating-contact-form-7-postmeta-options/ wp post-type list wp help post wp help taxonomy wp help term ... You should scroll down (press J key as vim naviate) to see Example usage. wp db query "SELECT meta_value FROM $(wp db prefix --allow-root)postmeta WHERE post_id = 300 AND meta_key = '_mail'" --allow-root wp post list --post_type=wpcf7_contact_form --allow-root wp post meta list 300 --allow-root Accessing Serialized postmeta with WP-CLI Scripting with WP-CLI In this simple bash script we create an array of all the Contact Form 7 post_ids. Then we use the post meta patch command to update each programatically via a for loop through the array. POSTIDLIST=($(wp post list --post_type=wpcf7_contact_form --field=ID --allow-root)) for POSTID in ${POSTIDLIST[@]}; do     wp post meta patch update ${POSTID} _mail use_html 1 --allow-root done wp post list --fields=ID,mycustomfield --meta_key=mycu