|
|
Ever needed to convert a video from one format to another? I needed to convert a flv to a mp4 yesterday and found that there were lots of programs out there that say they can do this. Some are free, some cost money. The first six I downloaded didn’t work at all. Then I found this:
http://onlinevideoconverter.com/
Worked like a charm. If you need to convert video from one format to another, that is the site to use.
<?= $variable ?> is depreciated in PHP5 (along w/ all other tags that are not <?php ?>). I don’t care so much about the others, but I actually use this one. <?= $title ?> just makes more sense than <?php echo $title; ?>
- The last instruction before a closing tag does not require a semicolon; however, this is probably a bug in the PHP parser and you should always terminate it anyway. Perhaps
<?= $variable ?> should actually be <?= $variable; ?>.
- use BCMath functions for precision math. This isn’t really obscure, but every now and then I run into people that have never heard of it, so it makes the list.
- Referring to a variable by-reference is slower than referring to a variable by-value (
&$a vs. $a)
- more to come….
So I got the project working on a tv schedule at work. As you can imagine there is work that needs to be done with dates and times when moving forward / back in the schedule. I found a few things out there that were full blown date/time js libraries, but they were a bit more than what I needed and didn’t do exactly what I needed. So I threw the following together. It does have specific stuff in it that is probably not portable to other projects, but here it is.
Continue reading Small JavaScript DateTimeTools object »
You know you have… if you are like me though, you can never remember the exact syntax. Here it is:
for (var name in object)
{
if (object.hasOwnProperty(name))
{
alert(name + ': ' + object[name]);
}
}
Ran into this recently. Not sure if it is a new “feature” of Mac OS X 10.5.7, or just the way my new AT&T U-verse router works.
Say you happen to do a clean install of Mac OS X (or any OS really), then connect to your wireless network, then do all the system updates, then finally get around to doing your custom settings.
One of the first things I change is the host name. I prefer themed names around something cool, vs. generic names like admins-mac-mini.local.
I fired up the System Preferences, went to the Sharing preference pane and changed the Computer Name from Admin’s Mac Mini to meimi. Did a few other things, restarted, fired up terminal and got this beautiful prompt:
admins-mac-mini:~ admin$
Hrm….
Come to find out the DHCP on my network has cached the initial name of the computer and just doesn’t want to let it go. I am sure there is some way to force it to update, but here is another way.
- Open up Terminal
$ sudo vim /etc/hostsconfig
- make sure you have the following line:
HOSTNAME="meimi.local" – change it to your hostname of choice and add .local to the end of it
If you are wondering what a dateCellEditor and asyncSubmitter are go check out http://developer.yahoo.com/yui/examples/datatable/dt_cellediting.html. See the last_login column? Click on that, you will get a cool calendar that pops up for you to change the date. Pretty handy. That Inline Cell Editing page touches on how to implement that, but it doesn’t cover the actual asyncSubmitter when using a dateCellEditor which is where I could have used a bit more information.
This example uses five files:
- index.html – template for the page
- javascript.js – javascript that powers the datatable
- datatabledata.php – back end process that returns the data for the datatable in JSON format
- update.php – back end process that updates the data in the database based on what the user changed
Below is a code example that spells it all out.
Continue reading YUI DataTable – Using a dateCellEditor with an asyncSubmitter »
Surprised I haven’t written this up before now. It is very simple to do.
This assumes you are using apache on a unix based system. This should work on any OS running apache though.
- In the directory you want to restrict create a file named .htaccess that contains the following:
AuthType Basic
AuthName "RESTRICTED ACCESS"
AuthUserFile /home3/speedtow/.htpasswd
Require valid-user
- Note: AuthName can be anything you want it to say and AuthUserFile must be an absolute path to the .htpasswd file. It can be anywhere, I wouldn’t recommend putting it in the directory you are restricting though, or any apache served directory for that matter.
- Create the .htpasswd file by running htpasswd in the location you want it to live. It will go something like this:
$ htpasswd -c .htpasswd username
New password:
Re-type new password:
Adding password for user username
Thats it, your done.
Example, getting all changes since r260, followed by all changes except deleted files.
svn log -v -r 260:HEAD | grep '^[ ]\{3\}'
svn log -v -r 260:HEAD | grep '^[ ]\{3\}' | grep -v '^ D' | cut -f3- -d/ | perl -ne 'if(/(.*)\/.*$/){print $1."\n";}' | sort | uniq
For entry, with my validator, I am validating that no matter what a user types in for a height, I convert it to a float to store in the database (5.10). In retrospect, I should convert it to the inches value, but this example isn’t doing that.
For display, with my formatter, I am standardizing the format to display as a proper height (5′ 10″).
All that is left is to get the column sort to not think someone that is 22′ tall is shorter than someone that is 3′ tall. For numbers to sort numerically, the type must be a Number, not a String. This could be easily accomplished with YAHOO.widget.DataTable.formatNumber, but I was hoping to be able to fix my problem of 5.10 changing to 5.1 here. I was not able to do that, as you can see by the commented out line below, so I took care of it in the validator (kinda).
Due to the lack of me finding, quickly, an example of a custom parser, I am posting this anyway, even though it is not really needed.
The parser is an object property defined in the array of objects defining the fields for the datasources responseSchema (assuming JSON).
STWPT.parseHeight = function (oData)
{
oData = parseFloat(oData); // convert to number (float)
// force decimal precision (5.1 > 5.10)
// this converts it back to a string
// oData = oData.toFixed(2);
return oData;
}
The following is a snippet out of a larger script that shows just the pieces that connect the datatable creation to the custom parser shown above.
var myDataSource = new YAHOO.util.DataSource('/path/to/datasource');
myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
myDataSource.connMethodPost = true;
myDataSource.responseSchema = {
resultsList: 'athletes',
fields: [
{ key: 'first_name', parser: 'string' },
{ key: 'last_name', parser: 'string' },
{ key: 'height', parser: STWPT.parseHeight }
]
};
var myDataTable = new YAHOO.widget.DataTable('athletes-datatable', myColumnDefs, myDataSource);
This is the validator I am using to insure that a height (or float) was entered (5′10″, 5′ 10″, 5.10 5 10), and that text (tall, short) was not entered and covert a valid non-float value entered (5′10″, 5′ 10″, 5 10) to a float (5.10), which is how I want to store the value in the database for this example.
Now that we have a custom validator created, it would be helpful to know where to call it from. A validator is an object parameter to the object that is sent to a textboxCellEditor.
The textboxCellEditor is an object parameter to the object that defines the column, in the array of objects that is sent to the datatable constructor.
STWPT.validateHeight = function (oData)
{
var pattern; // regexp pattern holder
// heightFormat is expected to be a decimal number for height
// add a space if none was provided (5'10")
// 5'10" -> 5' 10 - note the trailing non-digit characters are dropped
pattern = /'(\d+)/g
if (pattern.test(oData)) { oData = oData.replace(pattern, " $1"); }
// turn a space into a decimal - 5 10, 5' 10" -> 5.10, 5' 10"
pattern = / /g;
if (pattern.test(oData)) { oData = oData.replace(pattern, '.'); }
// remove all single and double quotes - 5' 10", 5'.10" -> 5.10
pattern = /["']/g
if (pattern.test(oData)) { oData = oData.replace(pattern, ''); }
// enforce x.0x format - 5' 1" -> 5' 01" -> 5.01
pattern = /\.([1-9])$/
if (pattern.test(oData)) { oData = oData.replace(pattern, '.0$1')};
// at this point we should have a float, which should eval > 0
if (oData > 0) { return oData; }
// validation only succeeds if a value is returned
}
The following is a snippet out of a larger script that shows just the pieces that connect the datatable creation to the custom validator shown above.
var heightEditor = new YAHOO.widget.TextboxCellEditor({
disableBtns: false,
asyncSubmitter: submitter,
validator: STWPT.validateHeight
});
var myColumnDefs = [{
key: 'height',
label: 'Height',
sortable: true,
resizeable: true,
editor: heightEditor,
formatter: STWPT.formatHeight
}];
var myDataTable = new YAHOO.widget.DataTable('athletes-datatable', myColumnDefs, myDataSource);
|
|