How to add multiple query folders in LINQPad? - linqpad

In the lower left corner of LINQPad, there is an area for display queries. One tab is My Queries and another one for Samples. I could not find a way to add more than one folder like in My Queries, just like one in Samples tab. I tried right click and checked all the menu items.
I'm not sure if I can change XML settings to include more than one folders in My Queries to organize my codes.
How can I have multiple query folders in LINQPad?

The answer I am adding here does not resolve the implicit question of, "how does one have multiple root level folders in LINQPad." However, I think it provides a solution to the question of, how "to include more than one folders [sic] in My Queries to organize my codes?"
Technique 1 - Just add folders (arguably worse than Technique 2)
You can have multiple sub folders under the My Queries folder, and they will all show up. This adds the benefit of being able to organize your queries a bit, with the downside being the fact that you will probably include a lot more files and folders than you intend to:
To add folders, just navigate to your My Queries folder in File Explorer, and add a new folder. Refreshing your My Queries pane will the display the new folder.
Technique 2 - Symbolic Links
You can achieve a similar result as Technique 1 by using symbolic links. The benefit to this approach is that you can link just the folders that you want (e.g. folders that contain scripts), while leaving everything else alone:
Please note that creating symbolic links typically requires administrative privileges on a computer.
Creating symbolic links is easy with Powershell:
# By not changing the value for "Path," this will create a symbolic link in the current folder
# that is named whatever value is given for "Name," and it will be pointed to whatever value
# "Value" is set to.
new-item -ItemType SymbolicLink -Path . -Name "ExampleSharedScripts" -Value "Path to actual folder"
The difference between the two techniques
To explain what is really different between the two techniques, I'll explain the folder structure from the pictures a bit more:
In technique 1, an entire repository is shown due to the fact that the entire repository is kept under the My Queries folder. In technique 2, my repository is stored somewhere else entirely, but I have added a symbolic link in my My Queries folder that points to the queries contained within the repository itself. Technique 2 allows me to store my repositories in a more appropriate place, while still allowing for the convenience of having scripts show up in the My Queries pane of LINQPad.
Other reading
A couple of blog posts have been put out on the internet with some tips and tricks around LINQPad. This blog post from Dan Clarke talks about how he creates symbolic links to manage his scripts (he also lists some other tricks).

There's no way to display more than one root folder in 'My Queries' at present. If you like, add a suggestion at linqpad.uservoice.com so we can guage demand.

LinqPad does not show empty folders in the tree so if you only created a folder you will also need to add a query for this to show in the tree. This has been something that has tripped me a couple of times.

Related

Edit files as if concatenated as one -- Do any IDEs or text editors have this feature?

Background: I am working with Angular (but my problem is not particular to any language or framework). In Angular, each component requires four separate files. So, we often find ourselves with 40+ files open. But, most of these files can be tiny, less than 20 lines each.
Many IDEs allow you to open your files in multiple windows. Each window can have a different panel, and each panel can have different tabs. This is great, but honestly, still isn't enough.
What I want: In addition to windows, panels, and tabs, I'd like to add another level of organization.
I speculate this has probably existed for decades, but I just don't know what it's called. At the very least, I speculate this has existed at least since Angular was a thing.
For example, here is a screenshot of VSCode with four files open across four panels. (Code taken from Angular dynamic component tutorial):
And here is a quick mockup showing what I'm looking for. Four files are open, but the three shortest ones are "concatenated" into one editor. Arrow-key down from the bottom of one file will bring you to the first line of the next file.
Notably, these files are not actually concatenated on-disk.
TLDR: What text editor can allow me to edit multiple files as if they were concatenated, as in the mockup above?
If the files stay as separate windows/tabs, the file editor would have to shrink each tab to a minimal height, and then tile them vertically. If any editor can do it, I suspect it would be emacs or vim. You might also be able to do it by opening separate editor windows and using a tiling window manager.
We can achieve a similar effect with some text editing magic. It would be something like:
Add a header to each file consisting of a unique separator (e.g. # === magic separator === filename my_file.js ===)
Use cat to combine all the files into one file
Edit this one file
When done, use the separator to break them up and put the text back into the original files
You could easily write some scripts for combining and splitting so you can do it quickly. You can also set up a background script that automatically runs the splitter as you edit the combined file. However, the combined file would essentially be a new file, so you could not view changes on it with git, and VS Code's CodeLens/Inline blame wouldn't work.
One option would be to develop your codebase with the combined files checked in to VCS, and then only have the splitter script as part of your "build" step. So you would make your changes, run ./build.sh which splits the files into some temp directory, and then run your application from there.
Lastly, and I hate to be snide, but the fact is that this problem is best solved by avoiding poorly designed frameworks that do not consider developer ergonomics. Many other languages give the developer much freedom and many tools to organize their code as they wish, rather than imposing constraints like requiring many small components to be in separate files. Java for example also had a similar problem (dunno if more recent versions fixed it) - you can only have one class per file, which creates a huge mess if you like having many small files. C# does not have this limitation and as a result C# codebases can be much tidier than Java codebases.

Comparison of files of two folders

I want to compare files of two folders in vb.net with respect of date time and size and put the odd ones in two list boxes for each folder. I am not getting through the logic. Can any one of you help me with logic or code?
Thank you.
Get the FileInfo for each file in each of the directories.
Compare the required properties of each.
Consider what to do if there are files in one directory which are not in the other.
Question scope is too wide to be covered on StackOverflow.
However, there is an open source project called DirComp.NET.
It looks like a good starting point for you.
DirComp.NET is a simple command-line tool written in VB.NET, which compares two directories, and either lists differences or mirrors one directory onto another. For example, it can be used to backup large file repository by maintaining a mirror copy. It lives well with existing Windows infrastructure, which already provides file shares. And finally, DirComp.NET is based on .NET Framework 2.0, which is available from Windows 2000 and up.

Logical file groups/folders in IntelliJ

I just created a project, and I notice immediately that I can't seem to right-click on my src folder and create a logical file group/folder within the project view.
In many IDEs, I can arbitrarily organize source files in groups/folders. These grouping help me organize my business process and data access layers appropriately.
How do I do the same in IntelliJ?
I'm not sure what the exact equivalent to what you're thinking is, or if there even is one.
IntelliJ has a notion of "scopes". Under the Project/navigation view, click the configure dropdown and choose "Edit Scopes...". From this window, you can define a pattern to include certain files from your project.
For instance, all of my DAOs are in packages called my.company.<feature>.persistence. I create a scope called "DAOs" with the pattern src[myProject]:my.company.*.persistence.*. Now when I choose "DAOs" from the Project view dropdown, I see a filtered view of the project. I haven't found a way to show that filtered view alongside other scopes at the same time, however.
These scopes can also be shared, and they can be used to narrow down searches. They are similar in many ways to Eclipse's working sets.
Many scopes are defined implicitly, like Test and Production, Changed Files, VCS changesets, etc.

Reference Items in context

I am trying to figure out a way to access the Items from the context without having to declare an ItemGroup explicitly.
Currently trying for the Copy task:
<Copy SourceFiles="C:\blabla\**\*.*" DestinationFiles="%(?.RecursiveDir)" />
What can I use in place of "?" to select the Items in context ?
The reason is that, I have an MSBuild project file being generated via XSLT and there are unknown number of folders & files (some of them follow a different structure under the destination folder - in that case I intend to use different meta data in place of RecursiveDir) in the input XML. Is it possible to achieve this without the need to declare loads of Itemgroups (or an Itemgroup with lots of Items) ?
I tried searching for this, but all I found were posts with Itemgroups declared.
#Alexey Shcherbak wrote:
You want to refer item metadata without explicitly declaring item itself, so I have doubts you will be able to do this. Also Copy task require that Source Files should be ITaskItem[] type (literally - it require item collection). Actually the msdn description of copy task has an exact example you could follow, but you should declare itemgroup with nested items clause inside.
You may wonder if you have an item with a lot of files, does it make MSBuild slow down.
The answer is: it depends =). What numbers you mean under huge fileset =). It's true that MSBuild engine emits and evaluates each item group in memory, and probably a huge fileset could lead to a bigger memory footprint. But MSBuild is not adapted to work as your scripting language of choice (even powershell has issues with 250K+ files in one dir, windows itself also). If you just need perform a copy without accessing to full meta (except recursive dir)- use Exec task and invoke robocopy.exe - it works waaaay better than anything else (considering available out of the box tools).
As an addition - huge numbers should be tested and evaluated before we declare that concrete tool isn't acceptable for that. I think as soon as MSBuild could deal with big solutions - it could probably deal with pretty big filesets. It just the resource/speed question. But any tool also have it's unsurmountable limits.
Actually I meant not robocopy extension, but robocopy.exe itself en.wikipedia.org/wiki/Robocopy, you can easily call it with Exec task. And surely hardlinks are unbeatable in terms of "copy" speed =). But keep in mind - it will work only across single disk volume (because it's not actual copy, it just adding another file name to same set of bytes =) ). In case you need actual copy to another drive or over the network - robocopy will shine again =).
PS: 20k files are far from my definition of huge ;) We dealt with ~280k-300k small files, summary volume around 80Gb. Powershell for plumbing and robocopy for actual bits-moving won that round.

Different letters for shared drives

Quick Background: I write excel macros for a company that uses shared drives on the network to share information between employees
The Problem: Different employees have the same shared drive listed under separate letters. For example Susie has the "Commissions Shared Drive" as drive "Z" but Betty has it as drive "x".
I'll design a macro that two different people use and the macro runs into errors because they have separate drive letters. To put it simply, the file locations written in the code won't be correct for both people due to the difference of drive letter.
The Current Solution: I currently have a copy of the exact same macro with changes made to the file locations to account for the difference of drive letter. This is annoying because anytime I make changes to the one file I have to ensure the other is exactly the same.
The Question: Is there a way I can account for different drive letters in one macro so I don't have to have duplicates of the file with different addresses?
Thanks in Advance!
-Mike
Use the actual network path.
For instance instead of something like
Z:\filename
Use
\\servername\foldername\filename
As long as the user has access to the path, the code will find it regardless of drive mapping.
Edit:
You can view this question and its answers for some great reasons why you should not use the mapped drive letters in your code.
As a side note, if you were using something less updatable then an Excel macro, it would be a good idea to not actually store the path in your code at all. Instead you would have a file that the code views to obtain the path. Thereby what you write will work far longer without having to be recompiled or revised. But again, since you're just doing an Excel macro I see no compelling reason not to use the direct path.
#Daniel Cook I also found another path that you can use to refer to a shared drive.
If you right click on the shared drive and go to properties > DFS (DFS is a tab in the properties window) they list a separate path there that works. I created a macro to test both paths and both worked.
However, one of my associates said he made a macro for another employee using the path method of \servername\foldername\filename and it didn't work on her computer for some reason, but when he used the other pathway found in the DFS tab under the shared drive's properties it worked for her.
Any ideas why the \servername\foldername\filename path might work on one computer and not another?