Skip to main content

Posts

Showing posts from 2020

Using phpword to merge two Mircrosoft Office Word .docx documents

How to combine or embed and insert another .docx file (Microsoft office docx word document) into another one using PHPWord Joining two .docx document using php ( phpword library ) $mainTemplateProcessor = new \PhpOffice\PhpWord\TemplateProcessor("file1"); //$mainTemplateProcessor ->setValue('var_name', $value); $innerTemplateProcessor = new \PhpOffice\PhpWord\TemplateProcessor("file2"); //$innerTemplateProcessor->setValue('var2_name', $value2); // extract internal xml from template that will be merged inside main template $innerXml = $innerTemplateProcessor->gettempDocumentMainPart(); $innerXml = preg_replace('/^[\s\S]*<w:body>(.*)<\/w:body>.*/', '$1', $innerXml); // remove tag containing header, footer, images $innerXml = preg_replace('/<w:sectPr>.*<\/w:sectPr>/', '', $innerXml); // inject internal xml inside main template $mainXml = $mainTemplateProcessor->gettempDocumentMainPart(

Teu Sonho - Online Interprete Seus Sonhos (teusonho.org)

Teusonho.org - Online Interprete Seus Sonhos https://teusonho.org é um software de interpretatação online de sonhos usando IA para análise em tempo real de sonhos repetidos e símbolos de sonhos.I took my website for dream analysis using Artificial Intelligence and Machine Learning that I have created in Hebrew https://dreamon.co.il and also in English https://understandmydreams.com and created a version in Portuguese https://teusonho.org with new dream symbols and new dreams. Peguei meu site para análise de sonhos usando Inteligência Artificial e Aprendizado de Máquina que criei em hebraico https://dreamon.co.il e também em inglês https://understandmydreams.com e criei uma versão em português https://teusonho.org com novos símbolos de sonho e novos sonhos . Also on twitter: https://twitter.com/OrgTeusonho  

Connecting to MySQL 8 from Old PHP version using mysqli

If you have upgraded your MySQL to MySQL 8 version and still using older version of PHP you might encounter a few problems in the connection using mysqli connector library. 1. The first problem we are going to solve is: php mysql 8: "Server sent charset (255) unknown to the client. Please, report to the developers" The problem is that MySQL have changed the default character set from utf8 to utf8mb4 and it is not supported by mysqli connector (nor PDO as I have checked) in older versions of php. "The default collation for utf8mb4 differs between MySQL 5.7 and 8.0 ( utf8mb4_general_ci for 5.7, utf8mb4_0900_ai_ci for 8.0). When the 8.0 client requests a character set of utf8mb4 , what it sends to the server is the default 8.0 utf8mb4 collation; that is, the utf8mb4_0900_ai_ci." https://dev.mysql.com/doc/refman/8.0/en/charset-connection.html The way to solve it easily (there are other ways, such as upgrading php or connectors and more ...) is to force MySQL 8.0 to

Simple system to track errors in code and find them easily

Hi, Here is a trick I developed during my years as a developer / programmer and team code leader. This system not just helps you to find the location of the error or warning in the code, but also who wrote it (without the need to open Git Blame or SVN log) and when was it coded in written. They say that grep (find in all files) is the best friend of the programmer. Hence if you see an error in text or log file, let's say "Error: can't find configuration file". So you copy the text and "grep" it. It might be you would find this string in a few places scattered around the code. So, we have started to give some Error Codes to the error. For example "Error: can't find configuration file (1029)". This will make it much easier and this unique error code is easy to search inside all the code files. So how do you keep all the Error Codes unique ? Maybe a new programmer will add the same code number. Do you keep a file with all Error Codes

Defragmentation and resizing to minimize HD size of a Virtual Machine Drive for Virtual Box

When creating a Virtual HD for Virtual Machine in Virtual Box, you can create a large disc space but the actual size on the disc can be much smaller until you fill it up. But after you fill it, and then delete and try to free space the size on the host disc still remain large. Here is how to resize the Virtual Drive HD on the host machine: You have to do the following steps: Run defrag in the guest (Windows only) Nullify free space: With a Linux Guest run this: dd if=/dev/zero of=/var/tmp/bigemptyfile bs=4096k ; rm /var/tmp/bigemptyfile Or: telinit 1 mount -o remount,ro /dev/sda1 zerofree -v /dev/sda1 With a Windows Guest, download SDelete from Sysinternals and run this: sdelete.exe c: -z (replace C: with the drive letter of the VDI) Shutdown the guest VM Now run VBoxManage's modifymedium command with the --compact option: With a Linux Host run this: vboxmanage modifymedium --compact /path/to/thedisk.vdi With a Windows Host run this: VBoxManage.exe modifymedium --compact c:\p

גרף שעוקב אחר התפשטות והדבקות נגיף הקורונה בארץ

העיתונות מפרסמת הרבה מספרים והרבה מלל. אז אני מנסה לתמצת את זה, ותמונה שווה יותר מאלף מילים וגרף שווה יותר. אז אני אוסף את פרומי העיתונות ועוקב כמה חולי קורונה חדשים יש לנו כל יום ושם את זה על גרף בשאיפה לראות מגמות, כמה נדבקים, כמה נדבקו בארץ מקורונה ולכמה תחלואה בארץ ישראל גורם הנגיף COVID-19.  ניתן גם לראות את המספרים הגולמיים של חולי הקורנה, הדבקות חדשות, חולים קשה וכמה הבריאו מהנגיף ישירות במסמך Google Sheets שיצרתי על חולי הקורונה . והנה גרף חולי הקורונה בארץ:

Firefox notifications permissions fix for non secured domains (http and not https)

I had a running internal service inside an organization intranet. We wanted to allow notifications ( web notifications ) but we couldn't. In order to allow notifications for website and domains, both Firefox and Chrome requires https. Quite annoying since it is an Intranet inside the organization. Trying to install a self-sign certificate or a signed certificate inside the organization (where there is no outside internet connectivity) it's really a pain in the a** and does not work well - and if you ask me it should be much easier and simple than it is. I found a nice bypass workaround to allow notifications from websites and domains without SSL, hence http:// and not https:// for Firefox. Firefox holds a file inside the Mozilla directory called permissions.sqlite which is a sqlite database file that holds the permissions for domains. You can add your domain there http://yourdomainname with permissions for notifications and it will work. I have created a demonstration

Fixing screen not waking up (xorg) on Ubuntu from command line

Sometimes after xubunutu screen is in hibernate mode the screen does not wake up. Open terminal ALT+CTRL+F1 (tty) Run:   sleep 5 && xrandr -d :0 --output 'eDP-1' --primary --auto Then switch fast back to the graphic mode (ALT+CTRL+F7) wait a few seconds for the screen to wake up. 'eDP-1' is the name of your screen You can see connected screens running     xrandr -d :0