Textpad syntax definition for files without extension - textpad

In Textpad, is there a way to assign a syntax definition to files without an extension? The default document class does not appear to allow assignment of a syntax definition file.
I want to assign my PHP definition to files without an extension.

I will avoid asking why you have PHP in files with no extension -- .php is always valid.
Try setting the syntax for the Default document class.

Related

"./src/**/*.{html,js}" in tailwindcss's content what does this asterisks mean?

Are this "*" mean anything like "." or ".." when we define path? I am not getting what those means. Why can't I specify the path in the usual way? I wanted to use paths like "../../XYZ" or something like that. But where is this asterisk coming from and what does it mean? Can I define the path in tailwind without using the asterisk?
If anyone can help I would be most glad. I am new to tailwind CSS so a little bit confused. Thank you.
The asteriks are used for dynamic imports for if you want Tailwinds to scan for content in any folder that is under ./src/ (asuming you are using ./src/**/*.{html,js} as content in tailwinds.config.js file. That means if you use ./src/**/*.{html,js}, the first two ** will look for any folder inside ./src, including subfolders.
So, for example, file path in your configuration file will most likely look like:
./src/**/*.{html,js}
./something-else/**/*.{html,js}
And these configured paths will "translate" to something like:
./src/folder1/file.html
./src/folder1/file.js
./src/folder1/subfolder/file.js
./something-else/folder1/file.html
./something-else/folder1/file.js
etc..
Which means if you add a file with the .js or .html extension in the specified folder(s), Tailwinds will automatically include these files in your project.
According to the documentation, you don't want to use really broad path configurations like /**/*.{html,js}' but rather use something like:
./components/**/*.{html,js}
See the Tailwinds content configuration documentation for more examples.
you can use * to match anything except slashes and hidden files,
and use ** to match zero or more directories.
check this site it will help you:
https://tailwindcss.com/docs/content-configuration

Best practice to parse multiple config files

What would be the best practice - if there is any - to parse multiple config files?
I want to parse the mysql server configuration and also write the configuration again.
The configuration allows to issue multiple lines like:
!includedir /etc/mysql.d/
So the interesting thing is, that some configuration may be located in the main file but other may be located in a sub file.
I think pyparsing only works on ONE single file or one content string.
So I probably first need to read all files and maybe restructures the contents like adding headers for the different files...
====main file====
[mysql]
....
!includedir /etc/mysql.d/
====/etc/mysql.d/my.cnf====
[client]
.....
I would only have one pyparsing call.
Then I could parse everything into one big data object, group the file sections and have the file names as keys. This way I could also write the data back to the disk...
The other possibility would be to parse the main file and programmatically parse all other files that were found in the main file.
Thus I would have several pyparsing calls.
What do you think?
In your pyparsing code, attach a parse action to the expression that matches the include statements, have it parse the contents of the referenced files or directory of files, then merge those results into the current parse output. The parse action would make the successive calls to parseString, your code would only make a single call.
See this new example added to the pyparsing examples directory: https://github.com/pyparsing/pyparsing/blob/master/examples/include_preprocessor.py

Overwrite an existing file programmatically

I have a QDialogBox where there is an option to upload a file.
I can upload files and save them to a folder. It works fine.
But if in case there is a file that already exists in the folder, I am not sure how to handle that scenario.
I want to warn the user that the file with same name already exists.
Is there a Windows API that I can use in this case? (because when we manually save an existing file, we get a warning, how can I use that?)
If someone can point me to that documentation, it will be great.
If you are using a QFileDialog, confirmOverwrite is activated by default, so, if getSaveFileName() returned a non-empty QString, then that means the user accepted to overwrite the file. Other way, you get an empty QString.
Then, you can check if the file exists, and remove it in that case, but you know that the user was Ok with that.
There is always a potential race condition when saving files. Checking to see if the file exists first is not safe, because some other process could create a file with the same name in between the check and when you actually write the file.
To avoid problems, the file must be opened with exclusive access, and in such a way that it immediately fails if it already exists.
If you want to do things properly, take a look at these two answers:
How do I create a file in python without overwriting an existing
file
Safely create a file if and only if it does not exist with
python
You can use QDir::entryList() to get the file names in a directory if you're not using a QFileDialog.
QDir dir("/path/to/directory");
QStringList fileNames = dir.entryList();
Then iterating through file names, you can see if there's a file with the same name. If you need it, I can give an example for that too. It'd be C++, but easily adaptable to Python.
Edit: Smasho just suggested that using QDir::exists() method. You can check if the file name exists in the directory with this method instead of iterating like I suggested.
if(dir.exists(uploadedFileName))

skip rules in msdeploy

I am passing several skip arguments to msdeploy in order not to synchronize(Delete and Update) some directories and files
-skip:skipAction='Update',objectName='filePath',absolutePath='.*\\documents\\.*'
It does not seem to work, some directories and files get deleted.
I am pretty sure there's no problem in the regular expression given to the absolutePath
Can anyone please clear up how the matching works for the skip rules?
It is clearly not working according to the regular expression and objectName.
Look here:
http://forums.iis.net/p/1192163/2031814.aspx#2031813
The way skip rules are applied is based on the order of the synchronization operation(delete, update, add) is done on the actual object(directory or file).
For example, if there's a delete operation on the directory, the skip rules for files within the directory for the delete operation will NOT PREVENT files from being get DELETED!
In my case, the directory MySite\MobileForms get deleted entirely. The skip rule I set for the files is useless.
And for the directory, my mistake is in the regular expression:
-skip:skipAction='Delete',objectName='dirPath',absolutePath='.*\\MobileForms\\.*'
Should be:
-skip:skipAction='Delete',objectName='dirPath',absolutePath='.*\\MobileForms$'
which says that it should skip deleting directory path MobileForms(the first rule erroneously included slash in the regular expression).
Hope this helps others as well.

Getting extension of the file in FileUpload Control

At the moment i get file extension of the file like :
string fileExt = System.IO.Path.GetExtension(filUpload.FileName);
But if the user change the file extension of the file ( for example user could rename "test.txt" to "test.jpg" ), I can't get the real extension . What's the solution ?
You seem to be asking if you can identify file-type from its content.
Most solutions will indeed attempt the file extension, but there are too many different possible file types to be reliably identifiable.
Most approaches use the first several bytes of the file to determine what they are.
Here is one list, here another.
If you are only worried about text vs binary, see this SO question and answers.
See this SO answer for checking if a file is a JPG - this approach can be extended to use other file headers as in the first two links in this answer.
Whatever the user renames the file extension to, that is the real file extension.
You should never depend on the file extension to tell you what's in the file, since it can be renamed.
See "how can we check file types before uploading them in asp.net?"
There's no way to get the 'real' file extension - the file extension that you get from the filename is the real one. If file content is your concern, you can retrieve the content type using the .ContentType property and verify that it is a content type that you are expecting - eg. image/jpg.

Resources