Why doesn't Find-String work on the output from Powershell commands? - select-string

I don't know if this is a problem on a larger set of Powershell library commands, but I'm using the Share Point Online library right now and can't get this to work:
Get-SPODeletedSite | Select-String "100060-24"
I can see that this string exists in the output if I just type "Get-SPODeletedSite", but when I try and filter for just the line that contains this text, it comes up empty. What's going on here? This is a basic piping operation.

PowerShell is an Object-Oriented language. As such, it is designed to work with Objects (Structures). PS has builtin instructions on how to present Objects on the screen but that is for display purposes only. That's the best explanation I can provide. Maybe someone with a better overall understanding of PS could offer a better explaination.

Related

How to change the value of wxDatePickerCtrl?

I have tried this, But I am not able to get date displayed on the datePickerCtrl.
Here SDOB is a wxDatePickerCtrl.
SDOB->SetValue(Rs.GetDate(3));
But I am able to get the date onto a label or text field by doing
wxStaticText11->SetLabel(Rs.GetDate(3).FormatDate());
But for my purpose I would like to get it onto the datePickerCtrl itself. Help!
Also where can I find good documentation with examples for wxWidgets? I am a beginner.
You're using the correct function for setting wxDatePickerCtrl value, so if you don't see what you expect, the date you pass to it must be invalid or otherwise different from what you think it is. Generally speaking, when asking about why something doesn't work you should explain both how do you expect it to work and what actually happens because otherwise nobody else can know what's really going on.
The documentation for this control is at https://docs.wxwidgets.org/3.1.4/classwx_date_picker_ctrl.html as could be expected and there are a hundred of examples distributed with wxWidgets, so if you want to see an example of this class in action, I recommend doing grep -lR wxDatePickerCtrl samples in the directory containing wxWidgets sources.
Good luck!

Regex help for somebody that realy need help - Visual basic

I'm actually starting creating a small language (in vb net, yes I know, maybe not a good idea).
I already started learning tutorials about regex, but apparently this function is saying me to get out).
I want to add some kind of commands, such as a command that allow you to arg. a /print command, something like:
/PRINT["Hello world";"blue";propety:{bold;italic}]
So, for me, the regex is :
"{{^\^{\|^#\^~\{}~\^]|\~^[}^\}^#~\[}~^\}^##{\~{^}^#\#~#}\^#}^]|\|}]#\|{"
So you understand that's not something I like writing.
Would you show me how to construct regex code for the first command I let?
Regex alone isn't the best way to create a language that, well, actually works.
Read this article for more info. I'm sure you can find better way to write a language if you really need to write it. In vb.net...
Anyway, if you insist on writing it in vb, I found a video that will help you with it.

How can I highlight different types of file in dired mode in Emacs?

In a nutshell, I want to have different faces for some types of file in dired mode. I don't think it matters, but I am using Aquamacs.
The example I will use here is .tex files. If I can do it for .tex, then I can just apply the same structure to do create other faces for other types of files.
From what I understand, I have to create a variable, write a regular expression, then apply a hook. I read a bit about regex and so far I have
^(.+)\.tex$
I think my structure and regular expression are not really correct. I am not a programmer (though I have an interest on it), I have only been using Emacs for 2 weeks or so, so any help would be greatly appreciated.
What I need is at least the basic structure of what I have to do. I understand there may be modes already created that do something similar (such as maybe Wdired and Dired-X), and I would not complain if someone told me about them, but what I really want is to have an elisp code (either already written or that I can work on), as I plan on learning a bit of elisp to be able to write my own customisations and this would be a way to learn.
Thank you!
Since you want to learn how to do it, try checking out the extension dired+.el. This mode does a lot more than what you want, but it does add new faces. Specifically, look for the variable diredp-font-lock-keywords-1 and how it is used. That should get you going.
Other SO questions that seem relevant are:
Match regular expression as keyword in define-generic-mode
Highlighting correctly in an emacs major mode
A hello world example for a major mode in emacs?

RTF / doc / docx text extraction in program written in C++/Qt

I am writing some program in Qt/C++, and I need to read text from Microsoft Word/RTF/docx files.
And I am looking for some command-line program that can make that extraction. It may be several programs.
The closest thing I found is DocToText, but it has several bugs, so I can't use it.
I have also Microsoft Word installed on the PC. Maybe there is some way to read text using it (have no idea how to use COM)?
Now, this is pretty ugly and pretty hacky, but it seems to work for me for basic text extraction. Obviously to use this in a Qt program you'd have to spawn a process for it etc, but the command line I've hacked together is:
unzip -p file.docx | grep '<w:t' | sed 's/<[^<]*>//g' | grep -v '^[[:space:]]*$'
So that's:
unzip -p file.docx: -p == "unzip to stdout"
grep '<w:t': Grab just the lines containing '<w:t' (<w:t> is the Word 2007 XML element for "text", as far as I can tell)
sed 's/<[^<]>//g'*: Remove everything inside tags
grep -v '^[[:space:]]$'*: Remove blank lines
There is likely a more efficient way to do this, but it seems to work for me on the few docs I've tested it with.
As far as I'm aware, unzip, grep and sed all have ports for Windows and any of the Unixes, so it should be reasonably cross-platform. Despit being a bit of an ugly hack ;)
Try Apache Tika
I recommend not to use COM as this would defeat the usage of a portable library like Qt in the first place.
You might want to use the classic catdoc or a similar tool such as wvWare.
Note that although the catdoc author claims that catdoc doesn't work under Windows, there is a posting of 2001 which states the opposite.
To read .doc files you can use the structured storage API. A .doc is basically a structured storage repository with various streams corresponding to the various parts of the document.
Be warned that it is quite a hairy API and that even using this API, a .doc file can be quite messy to look at.
Ofcouse this is still windows only but atleast it's not COM. just a plain old C API.
This might help. It is cross-platform and has an API http://www.winfield.demon.nl/
Otherwise the iFilter methods are the way to go if this is windows only. It will allow you to parse anything that has an iFilter on your system. Here is examples of this http://the-lazy-programmer.com/blog/?p=8 . I have used iFilter from the C# end of things quite a bit.

HD Regular Expression Search

I am working on a project for my computer security class and I have a couple questions. I had an idea to write a program that would search the whole hard drive looking for email addresses. I am just looking for addresses stored in plain text since it would be hard to find anything otherwise. I figured the best way to find addresses would be to use a regular expression.
I wrote an application in C# that works fairly well but it I would like to see if anyone has any better ideas. I am completely up for writing this in another language since I'm assuming C# isn't the best for this type of thing. So far the application I created just starts at the C:/ and recursively locates all files on the drive skipping those that aren't accessible. It also skips all common image, video, audio, compressed, and files over 512mb. This speeds it up quite a bit but there is a small chance that a large file could contain something useful. It takes about 12 seconds to generate the list of files and I'm guessing about an hour to check them all. One downside is that it uses about 50% cpu while scanning.
I'm looking for ideas on how to improve the search. Is there a faster way, a more efficient way, a more thorough way, things like that? I was trying to think if there was any way that you could tell if the file would contain plain text strings or not. Just let me know if you have any cool ideas. Thanks.
To be honest, the easiest existing way to do this is to use grep. As you improve your program, compare your speeds to it, and when you get close, stop worrying about optimizing. Alternatively, take a look at its source for an example of an existing product that does what you're looking for.
As noted elsewhere, tools already exist for this if you install Win32 ports of UNIX tools. Alternatively, the Windows equivalent is:
for /r c:\ %i in (*.*) do findstr /i /r "regular expression" "%i"
you should just use grep + find. grep is optimized for searching files fast, and find is optimized for providing lists of appropriate files for things like this. people have spent a long time optimizing these tools - no need to reinvent the wheel.