28 July 2021

Can not open PPT

 Can not open PPT


Symptom

When opening a PPT, 'PowerPoint found a problem with content in xxx.pptx. PowerPoint can attempt to repair the presentation.

If you trust the source of this presentation, click Repair.'

After you click 'Repair', you get

'There was an error accessing xxxxx.pptx.'

If you click 'Show Help', you get

'This error can be caused by the following conditions:

. Your hard drive or floppy drive has a corrupt section (damaged track or sector).
. A temporary operating system or network failure has occurred.
. Your network is unavailable, slow, or is corrupting data packets (failure of a router, network card, or noise on the network transmission line).
. Your antivirus program may be causing problems accessing certain files.

In the case of a damaged disk, you must save the file to another location (for example, a different drive).

In the case of a failure of the operating system, ...

If the network is experiencing problems, ... consult your network administrator.'

You click OK, you see nothing.


Solution

Click 'File -> Options -> Trust Centre -> Trust Centre Settings... -> Protected View',

Clear all the tick marks. Click OK.

You open the .pptx file fine now.

27 July 2021

How to concatenate all the text files in a directory with Python?

 How to concatenate all the text files in a directory with Python?


https://stackoverflow.com/questions/13613336/python-concatenate-text-files

import glob2

filenames = glob2.glob('*.txt')  # list of all .txt files in the directory

with open('outfile.txt', 'w') as f:
    for file in filenames:
        with open(file) as infile:
            f.write(infile.read()+'\n')

How to set pseudo class attributes within the body part of a web page?

 How to set pseudo class attributes within the body part of a web page?

https://stackoverflow.com/questions/1033156/how-to-write-ahover-in-inline-css


html


<a href="https://www.google.com/" class="one">Hello World</a>


css


.one {

text-decoration: none;
}

.one:link {
text-decoration: none;
}

.one.visited {
text-decoration: none;

.one:hover{
text-decoration: none;
}

.one:active{
text-decoration: none;
}

09 July 2021

How to get lost files back resulting from running git add and git restore -s@ -SW?

 How to get lost files back resulting from running git add and git restore -s@ -SW?


Problem

suppose you ran

$ git add .

then you ran

$ git status

and saw that you have added some files which you did not want to add. 

(You did not run 

$ git commit

)

then you wanted to remove them from the index.

In haste, you ran 

$ git restore -s@ -SW

resulting in those files are gone away from your working tree (resulted from -W).

You want to get them back.

Solution:

Run

$ git fsck --cach --no-reflogs --lost-found --unreachable head

You will get a list of SHA1, which point to your lost files.

Then run

$ git show SHA1 > name_of_lost_file

one by one, every lost file will now be in your current work directory!


01 July 2021

How to find all the files containing the string 'abc' in the current directory and all the sub-directories

How to find all the files containing the string 'abc' in the current directory and all the sub-directories?


find . -type f | xargs fgrep '...'