What do you do if you need to iterate over a lot of loaded entities during a single request or background process, like a Drush command? I thought it would be as easy as this …
Here is a quick script I use to delete local git branches by a prefix. I like to branch a lot, so I usually end up with tons of branches related to tickets etc.. This provides a simple way to remove them by a particular pattern. Yes, you could just use an alias and one of the commands in the comment below. However, that does not really give you the chance to easily see the branches that will be removed and confirm. With a simple Ruby script, this can be done in a couple of minutes. Plus it’s more fun (and less eye burning than a bash script)!
Tip: Name this script
git-branch-delso it can be invoked as a git command, like
I recently wanted to populate some content on a page via AJAX in Drupal 7. It is easy enough to just do something like this:
Great. Everything is dandy, until the content you have
#attachedassets from the content you have rendered on the server side (or anything added with
drupal_add_(js|css|library) too). A simple AJAX request like this will give you the generated HTML but means you cannot easily update the assets for the page and re-attach Drupal behaviors.
I have not had a chance to look at integrating PsySH settings for this directly with drush settings yet. Hopefully sometime soon I will open a pull request to integrate shell settings with drush better. So for now, I just use the config file functionality that comes bundled with PsySH to add a config file. See here for more details.
I see a lot of people using things like on the command line: