Recently in Code snippets Category
If you've created a new domain using xen-tools you might run into the situation that the console works, but if you SSH in you get:
"PTY allocation request failed on channel 0" and "stdin is not a tty"
You need to install udev. Connect via console (xm console <domain id>) (you can get <domain id> with xm list) and simply run:
apt-get install udev
And restart / stop+start. Problem solved!
PS: Don't forget to apt-get install build-essentials
"PTY allocation request failed on channel 0" and "stdin is not a tty"
You need to install udev. Connect via console (xm console <domain id>) (you can get <domain id> with xm list) and simply run:
apt-get install udev
And restart / stop+start. Problem solved!
PS: Don't forget to apt-get install build-essentials
For a client of mine we've been using mobile sync. To send the settings we use OTA OMA. Basically we make a XML file with settings, convert to WBXML. A good start guide can be found on http://mobiforge.com/developing/story/email-configuration-sms
I've found that sony ericsson phones (unlike Nokia) is more touchy on how to send username+password for sync (w5 type) application. This is a OK XML for SE+Nokia:
"<?xml version=\"1.0\"?>"
"<!DOCTYPE wap-provisioningdoc PUBLIC \"-//WAPFORUM//DTD PROV 1.0//EN\" \"http://www.wapforum.org/DTD/prov.dtd\">"
"<wap-provisioningdoc version=\"1.0\">"
"<characteristic type=\"APPLICATION\"> "
" <parm name=\"APPID\" value=\"w5\"/> "
" <parm name=\"NAME\" value=\"Radarspot LAB\"/> "
" <characteristic type=\"APPADDR\"> "
" <parm name=\"ADDR\" value=\"www.radarspotlab.com:8080/funambol/ds\"/> "
" </characteristic> "
" <characteristic type=\"APPAUTH\"> "
" <parm name=\"AAUTHNAME\" value=\"%s\"/> "
" <parm name=\"AAUTHSECRET\" value=\"%s\"/> "
" </characteristic> "
" <characteristic type=\"RESOURCE\"> "
"<parm name=\"URI\" value=\"card\"/>"
"<parm name=\"NAME\" value=\"Contacts DB\"/>"
" <parm name=\"AACCEPT\" value=\"text/x-vcard;2.1,text/vcard;3.0\"/> "
" </characteristic> "
" </characteristic> "
"</wap-provisioningdoc>";
(Forgive me for the quotes, it's copy/past)
I've found that sony ericsson phones (unlike Nokia) is more touchy on how to send username+password for sync (w5 type) application. This is a OK XML for SE+Nokia:
"<?xml version=\"1.0\"?>"
"<!DOCTYPE wap-provisioningdoc PUBLIC \"-//WAPFORUM//DTD PROV 1.0//EN\" \"http://www.wapforum.org/DTD/prov.dtd\">"
"<wap-provisioningdoc version=\"1.0\">"
"<characteristic type=\"APPLICATION\"> "
" <parm name=\"APPID\" value=\"w5\"/> "
" <parm name=\"NAME\" value=\"Radarspot LAB\"/> "
" <characteristic type=\"APPADDR\"> "
" <parm name=\"ADDR\" value=\"www.radarspotlab.com:8080/funambol/ds\"/> "
" </characteristic> "
" <characteristic type=\"APPAUTH\"> "
" <parm name=\"AAUTHNAME\" value=\"%s\"/> "
" <parm name=\"AAUTHSECRET\" value=\"%s\"/> "
" </characteristic> "
" <characteristic type=\"RESOURCE\"> "
"<parm name=\"URI\" value=\"card\"/>"
"<parm name=\"NAME\" value=\"Contacts DB\"/>"
" <parm name=\"AACCEPT\" value=\"text/x-vcard;2.1,text/vcard;3.0\"/> "
" </characteristic> "
" </characteristic> "
"</wap-provisioningdoc>";
(Forgive me for the quotes, it's copy/past)
This is a mental note to myself. Somethings using pre-installed VPS the PHP executed by Apache is lacking the necessary permissions to run binary files (shellscript and built-in commands works fine though). It doesn't generate errors, it simply doesn't work.
Those VPS often has the PHP-CGI version installed and thus you can:
#!/usr/bin/php
<?
exec('/home/user/www/mybinaryfiletoexecute');
?>
Note that the binary file must be in your www-dir.
Those VPS often has the PHP-CGI version installed and thus you can:
- Make your PHP script execute a shell script
- Init the shell script with PHP-CGI
- Execute
#!/usr/bin/php
<?
exec('/home/user/www/mybinaryfiletoexecute');
?>
Note that the binary file must be in your www-dir.
Every now and then you have the (miss fortunate) to need sIFR. I usually go for the jquery plugin. However, jquery sIFR measures the width of the html text (not the block itself) and then creates a matching flash. Since flash text is often wider, a line break appears.
Thus - jquery sIFR needs support for css width.
In jquery.sifr.js, efter line 297 (sendOptions[height]), add:
if( $each.css(width) !== "auto" ) {
sendOptions[width] = $each.css(width).replace('px','');
}else{
sendOptions[width] = sendOptions[width] || $alt[0][offsetWidth] || $alt[0][parentNode][offsetWidth] || $each.css(width);
}
Works for me..
Thus - jquery sIFR needs support for css width.
In jquery.sifr.js, efter line 297 (sendOptions[height]), add:
if( $each.css(width) !== "auto" ) {
sendOptions[width] = $each.css(width).replace('px','');
}else{
sendOptions[width] = sendOptions[width] || $alt[0][offsetWidth] || $alt[0][parentNode][offsetWidth] || $each.css(width);
}
Works for me..
From time to time you have the need to duplicate an mysql database, here's how you do it:
mysqldump -u DB_user --password=DB_pass DB_name | mysql -u DB_user --password=DB_pass -h DB_host DB_name
Source
Sometimes you feel the need to have custom fonts in HTML and you feel like SIFR is the way to go. However, your happy feelins are battered because of your SIFR plugin line breaks at the wrong place. Often it's the last word that doesn't fit.
This problem occurs because SIFR measures the HTML width of the text. Depending on your custom font it's most likely less then your flash needs to be. You can solve this by adding:
letter-spacing: 100%;
or depending on your font:
letter-spacing: 30px;
To your CSS. It doesn't effect your none-sifr layout (if js is turned off) but it solves the sifr issue.
Source
This problem occurs because SIFR measures the HTML width of the text. Depending on your custom font it's most likely less then your flash needs to be. You can solve this by adding:
letter-spacing: 100%;
or depending on your font:
letter-spacing: 30px;
To your CSS. It doesn't effect your none-sifr layout (if js is turned off) but it solves the sifr issue.
Source
For a multimedia project one of our clients at Happyplace wanted to burn a CD with:
- Audiotrack for stereos/car players
- PC Data with a flash projector which autostarts
- Mac data with a finder window that auto opens
- Collect all PC data, add the autostart.inf and all that.
- Collect all Mac data and store it in a .dmg (more on this later)
- Burn the audio CD, make sure you use "write session" and not "write disc"
- In Toast -> Preferences -> Show legacy formats and settings
- Burn a custom Hybrid with the PC data and the mac .dmg
- Using the disc utility, create a new disc with a size that fit your needs (I used 100MB)
- Add all the data you need
- Set the finder background and size as you want, originize the icon you wish to show (I only show the .app file)
- Close and re-open the finder window to save you settings
- (You need to have Xtools installed for this) run the terminal command "/Developer/Tools/SetFile -a V /Volumes/Mounted Disc/file" to hide the file "file" on "Mounted Disc". This will make the file invisible
- To make the finder window autoopen, use: udo bless -folder /Volumes/Mounted \Disc/ -openfolder /Volumes/Mounted \Disc/
- That's it. Cool!
For various reasons, you might end up needing to put your mod_rewrite syntax in your httpd.conf, usually if you want to use basic rewriting, but with .htaccess support turned of.
In that case, you need to be aware that you need to add a / for it to work, like this:
From http://drupal.org/node/9418:
herefore :
becomes
in my case
In that case, you need to be aware that you need to add a / for it to work, like this:
From http://drupal.org/node/9418:
herefore :
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]becomes
RewriteRule ^/(.*)$ /index.php?q=$1 [L,QSA]in my case
Some of us does not have a approved SMTP server on our development server, or are working outside the office. So how do you then send email when using Django as your python framework?
The answer is simple: Gmail
You will need:
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = '<user>@gmail.com'
EMAIL_HOST_PASSWORD = '<password>
EMAIL_PORT = 587
EMAIL_USE_TLS = True
That's it. Given, you can't use it in your production environment. But it works like a charm during development. And if you need help sending html mail with alternative content (html+txt), check out Ross Poultons article Easy Multi-Part E-Mails with Django
The answer is simple: Gmail
You will need:
- A gmail account
- Django (of course...)
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = '<user>@gmail.com'
EMAIL_HOST_PASSWORD = '<password>
EMAIL_PORT = 587
EMAIL_USE_TLS = True
That's it. Given, you can't use it in your production environment. But it works like a charm during development. And if you need help sending html mail with alternative content (html+txt), check out Ross Poultons article Easy Multi-Part E-Mails with Django
By default, both Firefox and IE limits the number of connections per server too 2. Upping the value to 6-8 is a good way if you want to:
Firefox:
Go to the location bar and type:
about:config
This will give you all configuration alternatives for firefox, find (or search):
network.http.max-persistent-connections-per-server
and make it above 2, below 10.
IE
Following these instructions..
- Browser faster (the connection limit is a usual bottleneck for fast connections)
- Download more then 2 files at the same time
Firefox:
Go to the location bar and type:
about:config
This will give you all configuration alternatives for firefox, find (or search):
network.http.max-persistent-connections-per-server
and make it above 2, below 10.
IE
Following these instructions..
