| [ 0 trackbacks ] | permalink | related link |




( 3 / 169 )Shadowbox is a great way to play FLV videos in a lightbox, but it is a little shortsighted in terms of the parameters it expects you'll want to pass onto JWPlayer. So here's a little workaround I came up with.
If you want to send a playlist position and repeat variable you need to modify the shadowbox-flv.js file as follows:
var D=["file="+this.obj.content,"height="+F,"width="+I,
"autostart="+C,"displayheight="+K,"showicons="+H,
"backcolor=0x000000","frontcolor=0xCCCCCC","lightcolor=0x557722",
'repeat='+(this.obj.repeat?this.obj.repeat:'false'),
'playlist='+(this.obj.playlist?this.obj.playlist:'none')]
Then you can send the params from your JS code:
Shadowbox.open({
player: 'flv',
title: 'FLV',
content: 'playlist.xml',
height: 400,
width: 550,
autostart: true,
repeat: 'list',
playlist: 'right'
});| [ 0 trackbacks ] | permalink | related link |




( 3 / 165 )I look forward to the day IE6 is wiped from the face of the internet like doomsday cults await their rapturous glory. I have read rumours - and I tend to agree - that IE6 is costing the world economy millions of dollars - I would like to see the figure properly researched, it could be billions!
Slowly we see big sites like YouTube phasing out IE6 support, slowly. Alas, I have client sites with 20% of visitors using IE6 so the end is not yet in sight...
The Tech Crunch story
What Ajaxian had to say about it
Join the list of sites not supporting IE6
| [ 0 trackbacks ] | permalink | related link |




( 3 / 137 )Using Symfony's observe_field() on radio buttons will work only the first time the value is changed. If a user changes the values more than once the onchange event stops firing. To get around this you need to use the onclick event instead (as observer_field() uses onchange - and to support keyboard events you need to add an onkeyup handler as well).
A solution was posted at Symfony nerds in the comments suggesting a hardcoded onclick Ajax call in the radiobutton() method. I suggest using the remote_function() instead to simplify the code, avoid duplication and allow the helper to do the work. After all, that's what helpers are for...
<?php
echo radiobutton_tag(
"tt_product",
1,
true,
'onclick=toolPref(1)'
);
?>
<?php
echo javascript_tag("
function toolPref(val){
".remote_function(array(
'url' => 'user/tallypref',
'with' => "'tally_product='+val"))."
}"
);
?>
| [ 0 trackbacks ] | permalink | related link |




( 3 / 128 )Thought this was worth posting as it could save someone a lot of grief. I had a slave MySQL server stop updating without warning. A SELECT SLAVE STATUS showed there was an error due to an existing record. This would have occurred when a SELECT DATA INFILE populated 50,000 records and things went a little haywaire. The solution was quite simple:
1. STOP SLAVE;
2. TRUNCATE TABLE table_name;
3. START SLAVE;
This wipes out all data in the table with errors and allows the master to rebuild it from scratch. If you have foreign keys you might need to turn them off first...
| [ 0 trackbacks ] | permalink | related link |




( 3 / 113 )Want your web app to send email from your gmail or google apps hosted email account? This way your messages are stored in your sent box. Here's how to do it with a failover to localhost (in case there is a problem with the gmail server or authentication)...
try{
$connection = new Swift_Connection_SMTP(
sfConfig::get("app_gmail_host"),
Swift_Connection_SMTP::PORT_SECURE,
Swift_Connection_SMTP::ENC_TLS
);
$connection->setUsername(sfConfig::get("app_gmail_username"));
$connection->setPassword(sfConfig::get("app_gmail_password"));
$connection->attachAuthenticator(
new Swift_Authenticator_PLAIN()
);
$mailer = new Swift($connection);
$mailer->disconnect();
echo "Using gmail..." . PHP_EOL;
unset($mailer);
} catch (Exception $e) {
echo "Using localhost..." . PHP_EOL;
$connection = new Swift_Connection_NativeMail();
}
//use our working mailer
$mailer = new Swift($connection);
Note you need to disconnect, destroy and recreate your SMTP mailer or else gmail will accuse you of trying to change identity!
| [ 0 trackbacks ] | permalink | related link |




( 3 / 102 )I have a couple of symfony sites that my clients like to test without messing up their data (go figure). By modifying the controller a little I can detect the subdomain from the URL and then switch the syfmony environment accordingly. Then, using a filter, I can put a demo stylesheet in place to make the site look different as well...
By using this technique you can have exact copies of an application without duplicating a single file!
Step 1 - Set up the subdomain
Create a new subdomain in the DNS and configure apache to accept it as an alias for the live site.
<VirtualHost *:80>
ServerName site.com
ServerAlias www.site.com demo.site.com
DocumentRoot "/var/www/"
</VirtualHost>
Step 2 - Create a new database for the subdomain and configure the databases.yml file
test:
propel:
class: sfPropelDatabase
param:
dsn: mysql://root:pass@localhost/live
demo:
propel:
class: sfPropelDatabase
param:
dsn: mysql://root:pass@localhost/demo
Step 3 - Modify the controller
Symfony 1.0:
//check for DEMO site
$env = "live";
$debug = false;
$domain = $_SERVER['HTTP_HOST'];
if (strpos($domain,"demo") !== false){
$env = "demo";
$debug = true;
}
define('SF_ROOT_DIR', realpath(dirname(__FILE__).'/../..'));
define('SF_APP', 'my_app');
define('SF_ENVIRONMENT', $env);
define('SF_DEBUG', $debug);
Or in Symfony 1.2:
$configuration = ProjectConfiguration::getApplicationConfiguration('my_app', $env, $debug);
sfContext::createInstance($configuration)->dispatch();
Step 4 - Create the filter
My favourite bit - save it in your lib folder:
<?php
class demoFilter extends sfFilter
{
public function execute ($filterChain)
{
if (SF_ENVIRONMENT == "demo" && $this->isFirstCall())
{
$this->getContext()->getResponse()->addStylesheet('demo','last');
}
// execute next filter
$filterChain->execute();
}
}
?>
Step 5 - Add your stylesheet & images etc
The above filter adds demo.css to each page, so create the file and any images it requires and upload to your existing css and images folders and you're done.
| [ 0 trackbacks ] | permalink | related link |




( 3 / 106 )I recently set up mySQL replication for a client and thought I'd share this quick and easy way of distributing database load over a few machines.
First, set up replication - it's very simple. Here's a simplified list of tasks based on the info at mysql.com:
http://forums.gentoo.org/viewtopic.php?t=241123
Then you need to adapt your site to use the master server for all write operations and distribute the read load across your slaves (and master if you like).
My setup was moving from a single server to 2 servers. The primary server runs apache and the master database. The secondary server takes all the database read traffic (high CPU low bandwidth) and also serves up media files (low CPU high bandwidth).
The way I set up the config for the databases was to allow for failover from the slave back onto the master. Now this site was built in 2003 and uses some very old PEAR classes (remember PEAR? ;-), but you get the idea:
$options = array(
'debug' => 2,
'portability' => DB_PORTABILITY_ALL,
);
$dsn = array(
'phptype' => 'mysql',
'username' => def_user,
'password' => def_pass,
'hostspec' => def_host,
'database' => def_dbname,
);
$db_master =& DB::connect($dsn, $options);
if (PEAR::isError($db_master)) {
showError($db_master->getMessage());
}
$db_master->setFetchMode(DB_FETCHMODE_OBJECT);
//use 2nd database server if available
//otherwise duplicate original as failover
if (defined('def_host2')){
$dsn2 = array(
'phptype' => 'mysql',
'username' => def_user2,
'password' => def_pass2,
'hostspec' => def_host2,
'database' => def_dbname2,
);
$db =& DB::connect($dsn2, $options);
if (PEAR::isError($db)) {
$db = $db_master;
}else{
$db->setFetchMode(DB_FETCHMODE_OBJECT);
}
}else{
$db = $db_master;
}
Then the next step was to modify the pages that included DELETE, UPDATE or INSERT queries to use $db_master instead of $db. The whole process took a little over an hour and the site was only offline for 20 minutes :)
| [ 0 trackbacks ] | permalink | related link |




( 3 / 140 )
How to add a Symfony command to PhpEd:
1. Menu: Tools->Settings
2. Go to Tools -> Integration
3. Click "Add Menu"
4. Enter "Symfony cc" in menu name
5. Select "Shell" from Execute with list
6. Enter php @ProjRoot@/symfony cc in command line
7. Select checkbox next to "Show this command in Workspace" group
8. Deselect "for files" checkbox
9. Select "for directories and projects"
Save and then try right-clicking on a project to run your command from the context menu.
You can also direct the output of the command line back into PhpEd's log panel - this is a good way to ensure your CLI commands are executing without errors - as the windows command prompt has a tendency to flash and disappear before your eyes...
| [ 0 trackbacks ] | permalink | related link |




( 3 / 199 )This has come in handy for a couple of mail queues I have built and thought it was worth sharing. Basically it's a small check for PHP in the running system processes. If *any* PHP script is running (besides itself) we abort the script. It would be nice to know *which* script was running but I haven't managed to do that yet :)
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
//windows, can't do thread detection
$threads = 1;
}else{
//check for PHP PID and abort
$pids = preg_split('/\s+/', `ps -o pid --no-heading -C php`);
$threads = 0;
foreach($pids as $pid) {
if(is_numeric($pid)) {
$threads++;
echo "Process " . $pid." found\r\n";
}
}
}| [ 0 trackbacks ] | permalink | related link |




( 3 / 162 )Back Next



Avatar



