I recently had a hard drive go bad on me which actually turned out to be a hard drive going bad. There was definitely something goofy going on with access to the drive. I keep daily backups but a perfect backup of a corrupted source is no good. My most important files are my digital photos, mostly JPG images. I did some visual spot checking but once I hit the 1500 photos I looked for a better alternative. Here’s what I came up with. (This works on Linux. You’ll have to alter your process on Windows and Macs but the principles are the same.)
Author: nerijuso
How do you cache an image in Javascript?
Once an image has been loaded in any way into the browser, it will be in the browser cache and will load much faster the next time it is used whether that use is in the current page or in any other page as long as the image is used before it expires from the browser cache.
Adding a custom button to the EZPublish online editor
A short explanation on how to add a custom button to the EZPublish online editor (ezoe).
Step 1: Setting up the extension
The custom button could be set up using an existing ezpublish extension or by creating a new one. Assuming you want to use a new extension, create a new folder called ‘newbutton‘ in the extension folder. Don’t forget to activate the extension by adding ‘ActiveExtensions[]=newbutton’ or ‘ActiveAccessExtensions[]=newbutton’ to your list of ExtensionSettings in site.ini.append.php:
Example how to add http:// to the url if there isn’t a http:// or https:// or ftp://
This is a simple php example how to add http:// to the url.
function addhttp($url) { if (!preg_match("~^(?:f|ht)tps?://~i", $url)) { $url = "http://" . $url; } return $url; }
Recognizes ftp://, ftps://, http:// and https:// in a case insensitive way.
Parse youtube video id using preg_match
This regex grabs the ID from all of the various URLs I could find… There may be more out there, but I couldn’t find reference of them anywhere.
New experience
WMPL get (post, page, category) dependent IDs
1) Automatically Adjust IDs
WPML can hook to WordPress API functions, detect when specific items are loaded and adjust IDs so that the results are adjusted for the active language.
This functionality is enabled by default and can be accessed via WPML->Languages (visible in Advanced mode):
This will automatically adjust all IDs and can be used in any WordPress theme that uses the API correctly (almost any theme you can find).
2) Manually, using the icl_object_id function
Alternatively, if the automatic ID adjustment is off, you can use the icl_object_id function to achieve the same manually.
icl_object_id(ID, type, return_original_if_missing,language_code)
- ID – the ID of the post, page, tag or category
- type – ‘post’, ‘page’, ‘post_tag’ or ‘category’
- return_original_if_missing – true if WPML should return the ID of the original language element if the translation is missing or false if WPML should return a NULL if translation is missing.
- language_code (optional) – if set, forces the language of the returned object and can be different than the displayed language.
The ID argument can be the ID of the object in any language. What the function will do is look up the translation group for that object and then the ID of the corresponding object in the active language.
Example usage
icl_object_id(3, 'category', false)
Return the ID of the category that is the translation of category 3. If it’s missing, return NULL.
Protect wordpress site with .htaccess
WordPress is the world’s most popular CMS with million users. This is how to secure your WordPress site with .htaccess.
How to disable backspace in browser?
Some it is necessary to disable backspace button in browser. This javascript code can help to disable backspace:
document.onkeydown = function () { var e = event || window.event; var keyASCII = parseInt(e.keyCode, 10); var src = e.srcElement; var tag = src.tagName.toUpperCase(); if(keyASCII == 13) { return false; } if(keyASCII == 8) { if(src.readOnly || src.disabled || (tag != "INPUT" && tag != "TEXTAREA")) { return false; } if(src.type) { var type = ("" + src.type).toUpperCase(); return type != "CHECKBOX" && type != "RADIO" && type != "BUTTON"; } } return true; }
Styles to reset css for all browsers
The goal of a reset stylesheet is to reduce browser inconsistencies in things like default line heights, margins and font sizes of headings, and so on.
The reset styles given here are intentionally very generic. There isn’t any default color or background set for the body element, for example. I don’t particularly recommend that you just use this in its unaltered state in your own projects. It should be tweaked, edited, extended, and otherwise tuned to match your specific reset baseline. Fill in your preferred colors for the page, links, and so on.