When you're working through some complex program logic, low level code like manipulating strings is a distraction to write and worse, when you come back to it six months later, it makes your code look long and daunting to get back into. With this in mind, I always try to wrap low level code in re-usable functions.
Here's one such handy little function which works just like PHP's native str_repeat but it will include the iteration count in the string itself and do some cleaning at the end. This is perfect for generating numbered lists, sql queries and a bunch of other uses.
Showing posts with label shortcuts. Show all posts
Showing posts with label shortcuts. Show all posts
10 December 2015
28 May 2012
Add Photoshop PSD & Illustrator AI folder thumbnails to all versions of Windows XP/2003/Vista/2008/7 32/64-bit
This is great. Adobe have never bothered to provide thumbnail support for windows machines. I dont know if this is because they are technically incompetent, lazy or they are just trying to promote their bloated Adobe Bridge viewer application. Either way, as you can probably tell from the tone, it bugs me. Users have been screaming for this no-brainer feature since photoshop first arrived on the windows platform in 1992. Yes that's 20 years ago. Anyway, I've been applying registry hacks and messing with dlls for years to get thumbnails going in windows explorer but I finally found this tool today which is a quick and simple solution that claims to work across all versions of both windows and Adobe CS.
The installer below makes windows automatically load thumbs for all versions of Photoshop and Illustrator in the normal windows folder view.
Continue Reading >
The installer below makes windows automatically load thumbs for all versions of Photoshop and Illustrator in the normal windows folder view.
17 July 2011
AS3: Simple, Powerful String Find & Replace all instances function for Flash Actionscript. Similar to PHP's str_replace replacement.
Continue Reading >
Labels:
Actionscript,
AS3,
functions,
shortcuts
05 June 2011
AS3 handy weighted random & rounding functions with decimal/floating point precision
Like a lot of the "improvements" Adobe made to Actionscript with AS3, the Math.random() function is now a pain in the ass. It only generates a floating point number between 0 and 1 so 99% of the time, you need a few lines of code to get your random on.
With time saving in mind, I've written this weighted random function which makes beautiful randomness a lot handier to implement. For best results throw this in a class package and include it in every project.
Here it comes...
Continue Reading >
With time saving in mind, I've written this weighted random function which makes beautiful randomness a lot handier to implement. For best results throw this in a class package and include it in every project.
Here it comes...
Labels:
Actionscript,
AS3,
functions,
shortcuts
06 May 2010
PHP: Ultimate get/fetch RELATIVE PATH function between 2 folders/directories/files/pages or root dir
I wrote these functions today when everything I found online that attempted the same job was either too bulky, or too restrictive. It took me flippin ages - far longer than it should have! But it has huge functionality and will be a great addition to the arsenal.
The main function relpath basically calculates the relative path from anywhere to anywhere on the same domain. Possible uses are listed below:
Continue Reading >
- Get relative path from the current page to the root directory of the local domain (rootpath)...
echo relpath(); //outputs ../../ or something similar - Get relative path from the current page to any other file/folder on the domain...
echo relpath("/scripts/javascripts/jsmin/min.js"); //outputs ../../jsmin/min.js - Get relative path from any file/folder on the domain to any other file/folder on the domain...
echo relpath("/scripts/connect.php","/scripts/javascripts/jsmin"); //outputs ../../scripts.connect.php
02 May 2010
PHP: Quick & handy browser sniffer/checker function/class
Yes, you can check your visitor's browser using PHP! What's more, it never goes out of date! It automatically updates to recognise the lastest browsers. As much as I'd like to, I can't take credit for this one - it's the work of Jonathan Stoppani and makes browser sniffing with PHP an absolute breeze.
This class (named Browscap) is a great alternative to PHP's native get_broswer function which requires manual regular updating of a browser.ini definitions file. Instead, Browscap intermittently imports the latest browser definitions from browserproject.com so that your scripts are always up to speed with the latest browser information.
Instructions and download below...
Continue Reading >
This class (named Browscap) is a great alternative to PHP's native get_broswer function which requires manual regular updating of a browser.ini definitions file. Instead, Browscap intermittently imports the latest browser definitions from browserproject.com so that your scripts are always up to speed with the latest browser information.
Instructions and download below...
28 April 2010
Javascript: Set or get URL/URI/src/href of an iframe or frame/frameset function
This function simply targets an iframe or frameset and retrieves or changes it's src or href attribute.
Continue Reading >
Labels:
Javascript,
js,
shortcuts
21 April 2010
PHP: Image resize function for calculating & constraining image proportions to fit in a box or space
I wrote this function on the back of my Actionscript version to calculate the output size of an image. If you only have a certain amount of space available in your page layout and you need to dynamically display an image that you don't know the size of, then this function is for you.
You simply specify how much space you have and the function will calculate the new size of the image proportionately and (optionally) return the html img tag for the browser. Sounds simple but it's incredibly useful and a lot easier than coding this each time you have need.
Continue Reading >
You simply specify how much space you have and the function will calculate the new size of the image proportionately and (optionally) return the html img tag for the browser. Sounds simple but it's incredibly useful and a lot easier than coding this each time you have need.
19 October 2009
Resize function for image or MovieClip with advanced options - Actionscript2 AS2
I found myself often needing to resize images to fit different spaces using actionscript so I wrote this handy function a while back. It allows you to quickly resize the image proportionally to fit your needs and doesn't require much thought. See usage examples below and you'll see what I mean.
Continue Reading >
Labels:
Actionscript,
AS2,
shortcuts
14 October 2009
mySQL to Flash import class - run queries from AS2 simply & automatically
mySQL2AS package with DataGrid...
This incredibly simple tool takes 5 minutes to set up and allows you to run mySQL queries and return results to flash using Actionscript 2 just as you can in PHP or any other language. Just 3 lines at the top of your flash document make mySQL queries a single function call away. You can loop through the results, trace them all to the output panel and even display them in a datagrid (a flash table) on the stage.
Continue Reading >
This incredibly simple tool takes 5 minutes to set up and allows you to run mySQL queries and return results to flash using Actionscript 2 just as you can in PHP or any other language. Just 3 lines at the top of your flash document make mySQL queries a single function call away. You can loop through the results, trace them all to the output panel and even display them in a datagrid (a flash table) on the stage.
Labels:
Actionscript,
AS2,
php,
shortcuts
Subscribe to:
Posts (Atom)