WordPress Media Library pre-processing with phpThumb
Certainly great things can be done to images with CSS3 and polyfills, and WP’s image editor is pretty keen… but sometimes you want some sort of image processing done in-between when you upload an image...
View Articlegetting the filename in JavaScript
weeee, nice little one liner: var filename = document.URL.replace(/^.*[\\\/]/, '');
View ArticleMove all x files recursively to a specific directory
Easiest way I know: find sourcedir -type f -exec mv {} targetdir \; Obviously, your filemask will probably be a bit more involved.
View ArticleList folders with file counts
find -mindepth 1 -maxdepth 1 -type d | while read dir; do count=$(find "$dir" -type f | wc -l); echo "$dir ; $count"; done
View ArticleRead a File Line By Line
Should be what you need 90% of the time in all shells: #!/bin/bash file="/export/home/jfishwi/paths.txt" while IFS= read -r line do # display $line or do somthing with $line echo "$line" done <"$file"
View ArticleJetpack Audio Embed Shortcode: A fix for Flash fallback not working
If you’re using all mp3′s or otherwise triggering flash fallback with your audio embed, check to make sure that the “player.swf” that Jetpack is trying to use is actually up. For example,...
View ArticleCount Photos in a WordPress Gallery
You may wish to display a count of the photos in your Gallery for a given post, possibly on the front index. I’ve often seen this done with SQL queries, which always made me cringe a bit. Its also...
View Articleworking with HTML5 getParent and getFile
I have a FileEntry that represents the following file/path: /cognitivemodelsaging/cognitivemodelsaging_lo.mp4 Whenever I call getParent() for the given FileEntry, it returns undefined. Frustrating....
View Article3.6 Audio: So what happens to blogs using the old JetPack shortcode for...
Long and short of it, WP 3.6 supports audio (meaning has a player for) out of the box. However, it doesn’t support playlists as JetPack audio did. Unfortunately, WP has adopted the JP convention of the...
View ArticleHandy Array functions
To find if a value is in an array: Array.prototype.contains = function (v) { for (var i = 0; i < this.length; i++) { if (this[i] === v) return true; } return false; }; e.g. var nums = [1,2,3,4];...
View Articlecontains() method polyfill
The contains() method determines whether one string may be found within another string, returning true or false as appropriate. Currently, this is an experimental technology, part of the Harmony...
View ArticleTranslating Programmer Speak
Doing some research on writing QA Test Cases at the erstwhile SoftwareQATest.com, and stumbled on this nugget: (On the topic of “Why does software have bugs?”) egos – people prefer to say things like:...
View ArticleCollapsing directories
Often I get a handoff where there are single files (or a few files) I need from each of a collection of dozens or hundreds of folders. So I’ll often want to “collapse” a directory of subdirectories,...
View ArticleJavascript: Return an array of objects according to key, value, or key and...
function getObjects(obj, key, val) { var objects = []; for (var i in obj) { if (!obj.hasOwnProperty(i)) continue; if (typeof obj[i] == 'object') { objects = objects.concat(getObjects(obj[i], key,...
View ArticleShebang!
A little CLI convenience for dealing with Python scripts. In my .bashrc: function shebang { sed -i '1s/^/#!\/usr\/bin\/env python\n\n' $1 chmod +x $1 } Prepends #!/usr/bin/env python and makes file...
View ArticlePosition element at the bottom of parent
Assign position:relative to the parent element, and then position:absolute; bottom:0; to the element. So for: <div id="container"> ehtoif <footer id="copyright"> Copyright James Fishwick...
View ArticleMissing cygwin1.dll Simple Fix: Put Cygwin in PATH
f you try running Cygwin from another program, or are running an installer (say for yasm) and you get a “missing cygwin1.dll” error, you should check that you have put Cygwin into your Windows PATH...
View Articleadvanced ffmpeg recipes
Output a single frame from the video into an image file: ffmpeg -i input.flv -ss 00:00:14.435 -vframes 1 out.png Output one image every second, named out1.png, out2.png, out3.png, etc. ffmpeg -i...
View ArticleDisable right click download for WordPress playlist
Add this JavaScript snippet: $(".wp-playlist").bind("contextmenu",function(e){ e.preventDefault(); }); …
View ArticleRemove duplicate lines with uniq
sort myfile.txt | uniq List only the unique lines: sort myfile.txt | uniq -u List only the duplicate lines: sort myfile.txt | uniq -d Get a count of the number of lines by adding the -c option. sort...
View Article
More Pages to Explore .....