How do you limit the number of files you want to view using winscp? - winscp

Is there anyway to load only selected number of files using winscp .. there are more than 50000 files which hangs my winscp!

This seems to be an issue faced by a few users and there doesn't seem to be a way to fix it. You might try one or more of the following:
When logging in, uncheck the option to Resolve symbolic links under Environment > Directories [doc]
Under Preferences > Transfer, uncheck the Calculate total size option [doc]
Try the command line
Not entirely sure about this one and whether it even makes sense in your case, but you might also try excluding/including certain file-types.[doc]
References:
https://winscp.net/forum/viewtopic.php?t=8379
https://winscp.net/forum/viewtopic.php?t=4215

Related

Is it possible to share SublimeText preferences *and* override one specific pref?

I share Sublime prefs between two machines (home, work) using Git.
My monitor at work has a higher DPI than my monitor at home, so in one of the two machines I'd like to override font_size.
I was hoping for:
The possibility to override using a command-line flag (to do something like subl --override-pref font_size=15), like kitty --override does.
Another level of prefs cascading below User.
, but I don't think any of this exists in Sublime. Language-specific config is not what I'm looking for, I want something global, but only in one of the two machines.
Ideas? Workarounds? Thanks.
The general mechanism at play for settings files is that when Sublime loads a sublime-settings file by name, it pulls all of the similarly named files across all of the known packages and combines them together (the same also happens for many other resource files) with content from later files overriding anything that appears in an earlier file.
The order that's imposed here is lexically by package, with Default always being first and User always being last. That's why the default settings are in the Default package and your custom settings are in the User package. Additionally syntax specific settings also apply (as do settings specific to projects).
Apart from this mechanism there's no direct way to override settings without some sort of manual intervention on your part. Potential solutions for this sort of problem include the following examples:
Don't sync the Preferences.sublime-settings file
If the file isn't synced across multiple machines, then this problem becomes moot because each machine can easily have it's own unique settings. The downside to that is that each machine then has it's own unique settings, which is a pain in the butt if you often move from machine to machine and things don't quite work the same way.
Use separate git branches
An alternative here if you're using git such as you are is to try and keep separate branches per host or per host type (like hi_dpi and reg_dpi or some such). Then on each machine check out the appropriate branch.
The obvious downsides here are having to try and cross-sync desired settings changes (for both User as well as any packages you might install) between branches, which is less than ideal unless you really love git.
Use extra Preferences.sublime-settings files
Here the idea is that you don't include the font_size setting in your User/Preferences.sublime-settings file at all. Instead, you use Browse Packages from the command palette to open the Packages folder, then create a new folder there with some arbitrary name. Inside of that folder include a Preferences.sublime-settings file that contains only the font_size setting.
Doing this on multiple machines, you can sync the settings in your User folder across machines without also syncing the preference that contains the font_size. As a note, if you create the file while Sublime is already running, you may need to quit and restart to get it to notice that the settings file exists; this only applies the one time, though.
Use a plugin
Looking at the link provided above, the ultimate trump card for any setting is a setting that's been applied directly to a view. Given that, you can use a plugin that selectively always applies a specific font size to any newly created or opened file:
import sublime
import sublime_plugin
import socket
class CustomFontListener(sublime_plugin.EventListener):
hostname = socket.gethostname()
def on_new(self, view):
if self.hostname in ("host1", "host1.example.com", "host2"):
view.settings().set("font_size", 20)
on_load = on_new
Now any time you open a file or create a new buffer, if the current hostname is in the list you've configured the view will immediately get an appropriate font_size applied; otherwise the one from the preferences would be used instead.
You could also extend this to be configurable via it's own settings file, apply a different font size depending on the host name, etc.
Settings in views are persisted in the sublime-session file and also in the workspace files associated with sublime-project files, so these settings will remain in place even across restarts.
Something to keep in mind is that the internal commands for changing the font size (via Preferences > Font or via the mouse wheel keyboard shortcuts) work by writing a new font_size to your user preferences.
If you're using separate preference files, then doing this will add font_size to your User settings and you will need to manually remove it and modify the other settings file.
If you're using the plugin, then these shortcuts won't seem to do anything because it applies a font_size that overrides the User preference, but in fact as outlined above your preferences file end up being changed and you may not notice right away.
So whichever way you go, if you tend to use those you may need to make manual adjustments to settings files in the aftermath. It's also possible to create smarter versions of those commands as well, if this is the sort of thing that happens often.

Ignore file extensions only on my machine

My team lead just added a lot of binary files that shouldn't be in source control. I have to pick and choose my battles with him and this isn't one I think is worth bringing up, but I'd like to just ignore these files on my machine without affecting everyone elses. Is this possible?
We're using TortoiseSvn. I've honestly never used the command line so until I learn how to do that I would prefer a solution using the GUI. Thanks!
If all your files resides in a special directory, you could simply use the Add to ignore list from the shell-context menu.
From the settings/general tab you can also add global ignore patterns, based on extension.

How to skip files which are in use with the SHFILEOPSTRUCT structure

I have a small problem with the SHFILEOPSTRUCT structure. I try to delete files in a temp directory. If there are some files in use the structure doesn't delete any file.
But I will delete all files, which are not in use without any display of a dialog.
How could I fix this?
As flag I use at the moment FOF_NOCONFIRMATION.
Edit
Oh I'm wrong. I use FOF_NOCONFIRMATION and FOF_NO_UI as flag and nothing happens. The structure returns 32.
If I just use FOF_ NOCONFIRMATION, a dialog box pop up and I could skip all files which are in use. All other files will be deleted.
If SHFILEOPSTRUCT can’t skip, how could I handle that problem?
I don't think it has that capability -- at least as far as I can tell, you're pretty much stuck re-implementing the same general capability if you want to continue without user intervention in spite of any problems that might arise.

"Show In - Explorer" with multiple files?

Here's a frequent situation: You have about thirty files checked out into a specific pending change-list. After working on those files, and before submitting them, you needed to move them to a folder (external to deposits, so a simple "Integrate" wouldn't be suitable).
Using the "Show In - Explorer" option, you'll get a lot of window popped-up. And that's just painful (and sometimes, the system just cannot open all of them).
So, question is, is there a simple way to copy-paste multiple files from a change-list without doing it individually?
You can do this with a custom tool.
In P4V, open the custom tools manager via the Tools->Manage Custom Tools... menu item
Click New->Tool... to open the Add Custom Tool dialog and enter these parameters (xcopy isn't the ideal app for this, but I'll talk about that later1)
alt text http://img202.imageshack.us/img202/6678/p4editcustomtool.png
Now you will be able to select all the files in your change list, right click on them, and a new item will be available in the context menu Copy selected files to another location..."
alt text http://img97.imageshack.us/img97/4003/p4vcustomtoolincontextm.png
An input box will appear, asking you where you wish to copy the files.
alt text http://img132.imageshack.us/img132/7612/p4locationprompt.png
Click OK and the files will be copied to the location you entered in the input dialog. Maybe...
1There are some problems with xcopy:
the target directory must already exist
it doesn't seem to work if the path contains spaces
if the process fails, you're process list will fill up with a bunch of instances of xcopy.exe that are stuck trying to do who knows what
the custom tool will no longer work if the previous condition occurs
I tried robocopy also, which would be perfect if there was a way to pass it the source directory, but P4V custom tool editor doesn't provide the parent directory as a parameter. Ideally, you should write your own file copy utility, if this is really important to you. It wouldn't require that much effort.
Lastly, the P4V custom tool editor offers a file browser, but not a folder browser, and the latter is what you really need for a tool such as this.
So, play around with the custom tool thing. You might be able to come up with an answer to your problem.
I know you want to do these things outside of Perforce, but the best I can think of is if you create another workspace specifically for exporting files. You can sync your Perforce workspace to contain only the files in a particular changelist.
In this workspace, try giving the files in your changelist, after it is submitted, a particular label. If you sync your workspace to this label, it will delete every file that does not have this label based on this Perforce page. (do Find for label in that page)
p4 sync #label_name
This involves Perforce, but it does provide a way to get only the files you want.
I believe you can also accomplish this only using changelist numbers, but it may be more complicated. I'm not 100% sure this works
p4 sync #none
p4 sync #changelist,#changelist
I think this will sync files only in this changelist.

linux script, standard directory locations

I am trying to write a bash script to do a task, I have done pretty well so far, and have it working to an extent, but I want to set it up so it's distributable to other people, and will be opening it up as open source, so I want to start doing things the "conventional" way. Unfortunately I'm not all that sure what the conventional way is.
Ideally I want a link to an in depth online resource that discusses this and surrounding topics in depth, but I'm having difficulty finding keywords that will locate this on google.
At the start of my script I set a bunch of global variables that store the names of the dirs that it will be accessing, this means that I can modify the dir's quickly, but this is programming shortcuts, not user shortcuts, I can't tell the users that they have to fiddle with this stuff. Also, I need for individual users' settings not to get wiped out on every upgrade.
Questions:
Name of settings folder: ~/.foo/ -- this is well and good, but how do I keep my working copy and my development copy separate? tweek the reference in the source of the dev version?
If my program needs to maintain and update library of data (gps tracklog data in this case) where should this directory be? the user will need to access some of this data, but it's mostly for internal use. I personally work in cygwin, and I like to keep this data on separate drive, so the path is wierd, I suspect many users could find this. for a default however I'm thinking ~/gpsdata/ -- would this be normal, or should I hard code a system that ask the user at first run where to put it, and stores this in the settings folder? whatever happens I'm going ot have to store the directory reference in a file in the settings folder.
The program needs a data "inbox" that is a folder that the user can dump files, then run the script to process these files. I was thinking ~/gpsdata/in/ ?? though there will always be an option to add a file or folder to the command line to use that as well (it processed files all locations listed, including the "inbox")
Where should the script its self go? it's already smart enough that it can create all of it's ancillary/settings files (once I figure out the "correct" directory) if run with "./foo --setup" I could shove it in /usr/bin/ or /bin or ~/.foo/bin (and add that to the path) what's normal?
I need to store login details for a web service that it will connect to (using curl -u if it matters) plan on including a setting whereby it asks for a username and password every execution, but it currently stores it plane text in a file in ~/.foo/ -- I know, this is not good. The webservice (osm.org) does support oauth, but I have no idea how to get curl to use it -- getting curl to speak to the service in the first place was a hack. Is there a simple way to do a really basic encryption on a file like this to deter idiots armed with notepad?
Sorry for the list of questions, I believe they are closely related enough for a single post. This is all stuff that stabbing at, but would like clarification/confirmation over.
Name of settings folder: ~/.foo/ -- this is well and good, but how do I keep my working copy and my development copy separate?
Have a default of ~/.foo, and an option (for example --config-directory) that you can use to override the default while developing.
If my program needs to maintain and update library of data (gps tracklog data in this case) where should this directory be?
If your script is running under a normal user account, this will have to be somewhere in the user's home directory; elsewhere, you'll have no write permissions. Perhaps ~/.foo/tracklog or something? Again, add a command line option, and also an option in the configuration file, to override this.
I'm not a fan of your ~/gpsdata default; I don't want my home directory cluttered with all sorts of directories that programs created without my consent. You see this happen on Windows a lot, and it's really annoying. (Saved games in My Documents? Get out of here!)
The program needs a data "inbox" that is a folder that the user can dump files, then run the script to process these files. I was thinking ~/gpsdata/in/ ?
As stated above, I'd prefer ~/.foo/inbox. Also with command-line option and configuration file option to change this.
But do you really need an inbox? If the user needs to run the script manually over some files, it might be better just to accept those file names on the command line. They could just be processed wherever, without having to move them to a "magic" location.
Where should the script its self go?
This is usually up to the packaging system of the particular OS you're running on. When installing from source, /usr/local/bin is a sensible default that won't interfere with package managers.
Is there a simple way to do a really basic encryption on a file like this to deter idiots armed with notepad?
Yes, there is. But it's better not to, because it creates a false sense of security. Without a master password or something, secure storage is not possible! Pidgin, for example, explicitly stores passwords in plain text, so that users won't make any false assumptions about their passwords being stored "securely". So it's best just to store them in plain text, complain if the file is world-readable, and add a clear note to the manual to warn the user what's going on.
Bottom line: don't try to reinvent the wheel. There have been thousands of scripts and programs that faced the same issues; most of them ended up adopting the same conventions, and for good reasons. Look at what they do, and mimic them instead of reinventing the wheel.
You can start with the Filesystem Hierarchy Standard. I'm not sure how well followed it is, but it does provide some guidance. In general, I try to use the following:
$HOME/.foo/ is used for user-specific settings - it is hidden
$PREFIX/etc/foo/ is for system-wide configuration
$PREFIX/foo/bin/ is for system-wide binaries
sym-links from $PREFIX/foo/bin are added to $PREFIX/bin/ for ease of use
$PREFIX/foo/var/ is where variable data would live - this is where your input spools and log files would live
$PREFIX should default to /opt/foo even though almost everyone seems to plop stuff in /usr/local by default (thanks GNU!). If someone wants to install the package in their home directory, then substitute $HOME for $PREFIX. At least that is my take on how this should all work.

Resources