Wa Web Utils

0 views
Skip to first unread message
Message has been deleted

Savage Doherty

unread,
Jul 16, 2024, 9:36:37 PM7/16/24
to jecciguty

Its absolutely a best practice! you don't want to mix all those utility functions with the rest of your application business logic. However, as your utils files and/or classes grow it is recommended to group them according to the function they provide.

wa web utils


تنزيل الملف ---> https://imgfil.com/2yZj0I



In other words, lumping together compression with image manipulation or the launching of external processes in a single class is a bad idea. By all means have a compression utility class and an image manipulation utility class but don't put them together.

Doing so is akin to using the singleton pattern as a god object, a ghetto where you just dump all your rubbish that should be better organised. I would say it's okay to use an uber-utility class during development but make sure your code is better organised before shipping. Maintenance will be a lot easier.

No, I don't think utilities classes are a good practice. Psycologically, the word 'Utilities' is just too broad and even if you split it into multiple classes *Util will just become a dumping ground for things that are 'too difficult' to fit into a proper class design.

For an example take a pseudo-ficticious StringUtils class. You could have hundreds of methods for encoding/decoding for different schemes, case transformations, handling whitespace, etc. A better approach, I think, is to use the strategy pattern to handle these transformations, which potentially would even allow for the possibilty of client code introducing new transforms without needing to edit/recompile the original code. You get a more powerful, more flexible and more maintainable system.

If it's at least static, then it makes sense in a Util class. That's easy! Cohesion and coupling are meant to make your life easier, this is a clear situation in which they wouldn't, so I would suggest to just keep it up your way.

Actually, the concept of Utils and Helper classes comes from the inability to write free functions in environments where every function need be owned by a class (either because of language or project restrictions). The Utils class with nothing but static functions ends up acting the role of a package with free functions.

Because it is a recurring phenomenon in many software projects, I'd consider it somewhat of an idiom to OOP designs, and therefore a Good Practice because people relate to it. As other replies point out, a beneficial enhancement would be to factor out your Utils classes to some separate project to facilitate reuse and maintenance.

My practice is to have both *Utils clases and *Helper classes. The former contains reusable static functions (for the case of Java and PHP) that are application-unrelated, where the latter are reusable application/domain logics - non static methods and usually with dependencies to other services/beans/managers.

Utility classes usually tend to produce procedure style code. The go against pure OO conventions. However, they simplify your life so use them. But have each one do it's own thing otherwise you will end up with a God class that will become a catch all for methods that don't quite seem to fit the object they should reside on.

I agree with Mike's comment. I use C#, but similar implementation. I have a util project that I maintain secretly and then just drop the DLL in the new project. That way as bugs/changes occur I can update projects simply by replacing DLL.

I would highly suggest, however, maintaining your utils in a separate jar or project (very easy with Eclipse). If you end up having multiple projects that use the same utilities, it is a good idea to avoid code replication. Having a project or jar to include is priceless.

How can I approach this package conflict? I can see here that "libblockdev" is meant to replace the utils version, but my system lists "libblockdev-utils" as a dependency for "libblockdev." Is there a way to update this dependency issue on my system? Is this a result of a different issue?

These packages are required by libblockdev. I don't like this solution though, because it marks all of these as explicitly installed, which prevents them from being uninstalled when they are no longer needed.

Actually I was not thinking about it much, just found the fast solution without thinking about these consequences. But it seems for me, that all packages remained marked as dependencies (they are not listed in pacman -Qe, but they are in pacman -Qd) - correct me if I am wrong.

I think I'm also experiencing this issue or something related. I'm using utils.downloadPage but I have quite a long page and it cuts off the last half. I tried using the componentsToInclude: ['Header', 'Main'] option but it doesn't work with that option. Any recommendations?

Every time i try to build any new project in Code composer studio i get this error "C:/ti/ccs1040/ccs/utils/bin/gmake" is not found in PATH ". Because of which i can't run any of my code. So please provide the permanent solution on this.

Assuming you installed CCS in C:\ti\ccs1040, if gmake.exe is missing then something went wrong with the CCS installation or the file got quarantined by your antivirus software or something similar to that effect. There should be five files in C:\ti\ccs1040\ccs\utils\bin. Do you see any other files in there?

You are missing gmake.exe. I don't know why this is happening. If a reinstallation failed also, then I suspect it is your antivirus that is removing the file. I would recommend you disabling it and try reinstalling and running CCS.

This discussion, however, is about naming consistency of files. Right now there are files named by as util or utils. It might be helpful to pick a consistent naming convention through out the code base.

I have spent a number of hours working to setup EFS under ECS Fargate using the instructions in this post -ecs-supports-efs/ and checked my JSON against the configure list _us/AmazonECS/latest/developerguide/efs-volumes.html without success. I have deleted the recreated the cluster, EFS instance, VPC and security groups without success. I also tried adding an IAM role which didn't help. Not sure what to do next.

My current error is "ResourceInitializationError: failed to invoke EFS utils commands to set up EFS volumes: command failed with 32: failed to execute command to invoke EFS utils: mount.nfs4: Connection reset by peer" when I try to start the Service with the EFS Task Definition enabled. As I understand it, Fargate should initiate these calls in a wrapper around the service, so I don't need to create a custom container image that includes the EFS Utils. Let me know if that isn't the case.

Turns out you needed to open port 2049 inbound on the security group on the network interface and task definition. It was not automatically setup even though I had it create the security group for me.

An iterable-style dataset is an instance of a subclass of IterableDatasetthat implements the __iter__() protocol, and represents an iterable overdata samples. This type of datasets is particularly suitable for cases whererandom reads are expensive or even improbable, and where the batch size dependson the fetched data.

When using a IterableDataset withmulti-process data loading. The samedataset object is replicated on each worker process, and thus thereplicas must be configured differently to avoid duplicated data. SeeIterableDataset documentations for how toachieve this.

For iterable-style datasets, data loading orderis entirely controlled by the user-defined iterable. This allows easierimplementations of chunk-reading and dynamic batch size (e.g., by yielding abatched sample at each time).

The rest of this section concerns the case withmap-style datasets. torch.utils.data.Samplerclasses are used to specify the sequence of indices/keys used in data loading.They represent iterable objects over the indices to datasets. E.g., in thecommon case with stochastic gradient decent (SGD), aSampler could randomly permute a list of indicesand yield each one at a time, or yield a small number of them for mini-batchSGD.

A sequential or shuffled sampler will be automatically constructed based on the shuffle argument to a DataLoader.Alternatively, users may use the sampler argument to specify acustom Sampler object that at each time yieldsthe next index/key to fetch.

A custom Sampler that yields a list of batchindices at a time can be passed as the batch_sampler argument.Automatic batching can also be enabled via batch_size anddrop_last arguments. Seethe next section for more detailson this.

This is the most common case, and corresponds to fetching a minibatch ofdata and collating them into batched samples, i.e., containing Tensors withone dimension being the batch dimension (usually the first).

When batch_size (default 1) is not None, the data loader yieldsbatched samples instead of individual samples. batch_size anddrop_last arguments are used to specify how the data loader obtainsbatches of dataset keys. For map-style datasets, users can alternativelyspecify batch_sampler, which yields a list of keys at a time.

The batch_size and drop_last arguments essentially are usedto construct a batch_sampler from sampler. For map-styledatasets, the sampler is either provided by user or constructedbased on the shuffle argument. For iterable-style datasets, thesampler is a dummy infinite one. Seethis section on more details onsamplers.

When both batch_size and batch_sampler are None (defaultvalue for batch_sampler is already None), automatic batching isdisabled. Each sample obtained from the dataset is processed with thefunction passed as the collate_fn argument.

When automatic batching is disabled, collate_fn is called witheach individual data sample, and the output is yielded from the data loaderiterator. In this case, the default collate_fn simply converts NumPyarrays in PyTorch tensors.

When automatic batching is enabled, collate_fn is called with a listof data samples at each time. It is expected to collate the input samples intoa batch for yielding from the data loader iterator. The rest of this sectiondescribes the behavior of the default collate_fn(default_collate()).

03c5feb9e7
Reply all
Reply to author
Forward
0 new messages