I'm using Laravel to gather directories from a drive using Storage::disk()->directories();. But I can see that it gathers all the hidden files as well, I'm using Windows so there is a few hidden folders i don't want it to gather. Is there a option or configuration to easily remove them? Or would I have to specify each item I don't want in the array and remove them one by one?
The ones I don't want to see in the array are things like: System Volume Information or $Recycle.bin etc..
You can use array filter to remove those that you don't want.
Something like that
$directories = array_filter(Storage::disk()->directories(), function ($directory) {
return !in_array($directory, ['System Volume Information', '$Recycle.bin']);
});
If you want a list of basic files that you may want to escape, you can take a look at that https://www.gitignore.io/api/windows
Related
Apologies if asked and answered already.
I'm making a custom application leveraging pdftk to merge a handful of documents. I'm trying to implement a method to arrange an array similar to
$pdfArray = Get-Childitem Full\Pathname | where name -like "*.pdf"
I need to devise a way for my user to be able to rearrange that array such that when the array is passed into the pdftk.exe /cat $pdfarray /output $outputname the docs are merged in the desired order (dont quote me on the command at all, just trying to illustrate the point). Im not above making the users name their files in such a way that its sortable but if i could make it easy for them to click move up/move down like a common pdf application would be ideal. Any ideas on a good approach?
I'm working on a little project in which CakePHP will be outputting script which will be interpreted by another client.
Thus far I have a layout setup which properly displays the script and only the script. I simply set it into an array, which each new line as a new row in the array. The view then just rolls through a foreach to display them, no problem. This is working perfectly.
Now what I would like to do is have cake slice and dice different pre-made script portions together. Basically I would store 'methods' as individual files of some kind, which can then be called by cakephp as needed and put together to make a single script.
What I'm wondering is:
a. If I'm following the cake conventions, where and how should these text files be stored?
b. What's the easiest way to call these files and set them into an array?
Thanks so much!
a.
I woud create a folder named Scripts/ in the app/View/Elements/ folder.
For each individual script, create a file in that folder. E.g. somefunction.ctp.
Those scripts can than be printed by calling echo $this->element('Scripts/somefunction'); (omit the '.ctp' extention)
b.
Putting the content of these files in an array could go like this:
array_push( code_array, $this->element('Scripts/somefunction') );
I am wondering if there is any available field in the .torrent files that could be used for some custom functionality in someone's implementation of a torrent client? For example, one might want to encode an URL to the file owner's website, someone else - some custom message to be displayed when opening the files, etc. Is something like this feasible in the current implementation of .torrent files?
Yes. .torrent files are just bencoded dictionaries and can hold arbitrary key-value pairs.
The main consideration when adding a custom field is to determine whether it should go into the root of the .torrent or inside the info dictionary.
If it goes into the root, it will not affect the info hash (which is the unique identifier of the torrent), and it will also not be available when downloading magnet links.
If it goes into the info dictionary, it is sort of locked down to the info-hash, in the sense that the info-hash depends on it. It will be transferred as part of the metadata when downloading magnet links and it cannot be changed (without changing the info-hash and thus creating a separate swarm).
So, if it's something you want 3rd parties should be able to change after the torrent was created, it should go in the root, if you want it to be entered once when the torrent is created and never change, it should go in the info dict.
I'm including a number of images as "Content" in my deployed XAP for Mango.
I'd like to enumerate these at runtime - is there any way to do this?
I've tried enumerating resources like:
foreach (string key in Application.Current.Resources.Keys)
{
Debug.WriteLine("Resource:" + key);
}
But the images aren't included in the list. I've also tried using embedded resources instead - but that didn't help. I can read the streams using Application.GetResourceStream(uri) but obviously I need to know the names in order to do this.
This is no API baked in to WP7 that allows you to enumerate the contents of the Xap. You need to know the name of the content items before you can retreive them.
There probably is some code floating around somewhere that is able to sniff out the Zip catalog in the XAP however I would strongly recommend that you don't bother. Instead include some sensible resource such as an Xml file or ResourceDictionary that lists them.
Having found no practical way to read the Content files from a XAP I build such a list at design time using T4.
See an example at https://github.com/mrlacey/phonegap-wp7/blob/master/WP7Gap/WP7Gap/MainPage.xaml.cs
This seems the right way to go as:
a) I'd rather build the list once at design time rather than on every phone which needs the code.
and
b) I shouldn't ever be building the XAP without being certain about what files I'm including anyway.
Plus it's a manual step to set the build action on all such files so adding a manual step to "Run Custom Tool" once for each build isn't an issue for me.
There is no way to enumerate the files set as "Content".
However, there is a way to enumerate files at runtime, if you set your files as "Embedded Resource".
Here is how you can do this:
Set the Build Action of your images as "Embedded Resource".
Use Assembly.GetCallingAssembly().GetManifestResourceNames() to
enumerate the resources names
Use
Assembly.GetCallingAssembly().GetManifestResourceStream(resName)
to get the file streams.
Here is the code:
public void Test()
{
foreach (String resName in GetResourcesNames())
{
Stream s = GetStreamFromEmbeddedResource(resName);
}
}
string[] GetResourcesNames()
{
return Assembly.GetCallingAssembly().GetManifestResourceNames();
}
Stream GetStreamFromEmbeddedResource(string resName)
{
return Assembly.GetCallingAssembly().GetManifestResourceStream(resName);
}
EDIT : As quetzalcoatl noted, the drawback of this solution is that images are embedded in the DLL, so if you a high volume of images, the app load time might take a hit.
Is there any way of organizing a icon collection so that it easier to find needed icons?
For example:
the program needs a save icon
there are 5 icons collections on your HD that have a save icon and there are 5 more collections that don't have a save icon (but you don't know that)
do you browse through each icon collection?
run a search (assumes files are named consistently)?
Would it be ideal to have some sort of organized directory (printable?)?
UPDATE
My process so far:
Use XXCopy to merge all icon folders into one folder.
Syntax = xxcopy "C:\Documents and Settings\jm\My Documents\Icons" "C:\Documents and Settings\jm\My Documents\All_Icons" /s /sr
Use Contact Sheets to add all files from the super folder and then export out contact sheets for all the images. This should sort them alphabetically.
Print and put in a binder -> now to find the actual file all you need to do is browse the binder, find the filename, and then search via Windows for the actual folder location.
In Visual Studio, there is a ZIP file with icons organized in folders. The organization is mostly by filetype and image size, is pretty messy, and contains many duplicates, so you should probably not follow their example.
However, they provide a HTML file in each folder that shows the icons in that folder in a nice readable list (better than Explorer's standard preview). You could do something similar, but maybe provide a table instead, for example with one column per collection, and one row per "concept" (e.g. save icon).