Quantcast
Channel: James Fishwick » Code Snippet
Browsing all 10 articles
Browse latest View live

Simple video info extraction with ffmpeg

To get a lot of information about a media file one can do ffmpeg -i <filename> It’s a little like drinking from a firehose though. How can we just quickly determine, say, if the video is h264...

View Article


Reverse line order in Notepad++

Input: Line 1 Line 2 Line 3 … Required Output: … Line 3 Line 2 Line 1 Edit > Select All TextFX > TextFX Tools > Insert Line Numbers If TextFX > TextFX Tools > +Sort ascending is checked,...

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


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


Get the current url in PHP, taking into account https and relevant port info

function getCurrentUrl() { $url = isset( $_SERVER['HTTPS'] ) && 'on' === $_SERVER['HTTPS'] ? 'https' : 'http'; $url .= '://' . $_SERVER['SERVER_NAME']; $url .= in_array(...

View Article


Link Checking using awk and cURL

If you are looking to check many thousands (or tens of thousands of links) and/or you’re interested in status codes, you’ll be better served by a scripted approach. Script is based off this BASH one...

View Article
Browsing all 10 articles
Browse latest View live