Increment integer value in a database field using WPDB

Sometimes you need to update values incrementally in your WordPress database. You might for example have an upvote feature to which you automatically add points in an incremental fashion.

It was surprisingly hard to find examples of how to do this using Wpdb. But here’s an example of doing just that:

/* Have to use wpdb->query instead of wpdb->update because the latter assumes strings  */
  $results = $wpdb->query($wpdb->prepare("UPDATE foodsenglish SET popularity = popularity + 1 WHERE dbID = %d", $foodIdToSendThePointFor), ARRAY_A);

Blender Video Editor Tips

Blender, being the Swiss-army-knife -tool that it is, can also do video editing. Setting up a video editing layout is easier than ever with the new “Workspace” -system of Blender. Simply click on the + button at the end of the workspace tabs and choose Video Editing –> Video Editing. Here’s a picture:

When using Blender as a video editor, a couple of questions immediately come to mind:

  1. How do I perform a cut? Answer: Simply press K.
  2. How do I perform a ripple delete (an edit in which the gap of the deleted content is automatically closed)? Answer: There is no ripple edit feature at the moment, but it can still be done very quickly by hitting “Del” to delete, then “Page up” to jump the playhead to the previous cut and finally “Backspace” to “Close gap”.
  3. How can I “render the timeline” for better playback performance? Answer: The best way might be to create Proxies. In the Proxy workflow, Blender will create new, better performing versions of your video files and use them for better work speed. These are the steps you need to take to enable Proxies in Blender Video Editor:

First find the Proxy Panel. It lives usually on the right side of the Sequencer (timeline looking panel). Select the clips you want to create a proxy for in the sequence. Click on “Set selected strip proxies” to set these clips up for proxy creation. It will ask for a desired proxy resolution. Then click “Rebuild Proxy and Timecode Indices”. Blender should now start creating the proxy files, next to your original files (although this location can be changed in the settings). It might take a while, but after it’s done, your playback should be much better.

Dealing with a multiresolution .mov file

For the first time in my career I encountered a video file that had two different resolutions. The beginning of the video was SD resolution and after 15 frames it jumped to a resolution of 1080p. VLC player was able to correctly switch the resolution during playback and it displayed the two different resolutions also in the codec information window. But Premiere Pro didn’t understand the file properly and never switched to the higher resolution portion of it. That was a problem because I wanted to use the high resolution in my edit.

Continue reading “Dealing with a multiresolution .mov file”