Quantcast
Channel: James Fishwick
Browsing all 23 articles
Browse latest View live

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 Article



getting the filename in JavaScript

weeee, nice little one liner: var filename = document.URL.replace(/^.*[\\\/]/, '');

View Article

Image may be NSFW.
Clik here to view.

Move 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 Article

List 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 Article

Read 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 Article


Jetpack 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 Article

Count 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 Article

working 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 Article


3.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 Article


Handy 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 Article

contains() 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 Article

Translating 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 Article

Collapsing 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 Article


Javascript: 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 Article

Shebang!

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 Article


Position 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 Article

Missing 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 Article


advanced 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 Article

Disable right click download for WordPress playlist

Add this JavaScript snippet: $(".wp-playlist").bind("contextmenu",function(e){ e.preventDefault(); }); …

View Article

Remove 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
Browsing all 23 articles
Browse latest View live




Latest Images