|
Mar, 9
2009
|
PHP: Check if current time is between 2 values |
|
Here’s a quick and easy script to check if the current time (by timezone) is between 2 predefined values:
function isbetween($s, $e) {
putenv("TZ=US/Eastern"); //Sets the current timezone
$ret = False; //Defaults to false
$n = date("G:i"); //Get current time in 24 hour format
$n = explode(':',$n); //Separate hours and minutes
$s = explode(':',$s);
$e = explode(':',$e);
$nt = $n[0] * 60 + $n[1]; //Convert time to total minutes
$st = $s[0] * 60 + $s[1];
$et = $e[0] * 60 + $e[1];
if($nt > $st && $nt < $et) //Check time
$ret = True;
return $ret;
}
if(isbetween('9:30', '16:00'))
{
echo "It is later than 9:30AM and earlier than 4PM EST";
}
|
Feb, 19
2009
|
Add the jQuery library to Smugmug! |
|
Smugmug is great, or at least really promising as an e-commerce site for photographers who want their work easily viewable with a lot of exposure. Smugmug also uses the YUI javascript library for it’s UI effects and functionality. I haven’t learned how to use or manipulate the YUI library yet, but I do know a bit of jQuery. So when my brother-in-law wanted to redesign his Smugmug site, I started to wonder. How the hell am I going to load the jQuery library in there, or will I have to teach myself YUI?? I don’t have the time to learn a new library and, as it turns out, jQuery has the functionality to sit side by side with YUI built right in!
The solution was pretty simple. First, you need to edit the “Head” of the site.
- Go to “tools>Go to my Control Panel” and click on “Site-wide Customization”.
- Within the “Head Tag” add these two lines:
<script src="http://ajax.googleapis.com/
ajax/libs/jquery/1.3.1/jquery.min.js" >
</script>
<script>
var $j = jQuery.noConflict();
</script>
This code does two things.
- It gets the jQuery library from the Google API source (v. 1.3.1)
- It loads the library using noConflict() mode, enabling you to use the library with other libraries.
It’s that easy. Now whenever you are writing your jQuery code, remember to use $j() for your jQuery calls instead of $(). More on jQuery’s noConflict() can be found here.
|
Feb, 16
2009
|
OSX: Finally, lock your screen |
|
So I was looking around at options to create a key combo to lock the screen on OS X Leopard. I came across several different options and none of them were really want I wanted. Some required running an apple script to start a screen saver, others require the key chain access application or having an icon on you menu bar or dock. All I wanted was a simple key combo to lock the screen. It’s as easy as 1-2-3…4-5-6-7-8. This is how you do it:
- Get Quicksilver if you dont already have it. So many good things come from this app that it’s worth it if not for this, then for it’s pure awesomeness.
- Enable fast user switching (System Preferences>Accounts>Login Options-last check box)
- Go into Quicksilver Preferences (default is option+space>command+,) and make sure you have the Extra Scripts and User Accounts Module enabled under plugins.
- Open the Quicksilver interface (option+space) and select “Fast Logout”, press ‘Tab’ then ‘right arrow’ to open up the command selections and select ‘Run: run a shell script’ and press enter. This should bring you to the user login window.
- If that worked, go back into Quicksilver Preferences (option+space>command+,) and select ‘Triggers’.
- Add a new trigger by pressing the ‘+’ symbol at the bottom. Select ‘Add new hotkey’. You should now see the default as the last command you picked (Fast Logout and ‘Run’).
- Click Save
- Now click on the ‘Trigger’ (it should say ‘none’) and select the hot key you wish to use. I chose to use ‘command+option+L’ as command+L has other functions.
That’s it. You can now lock your Mac to your heart’s content with a simple keystroke.