Sunday, January 2, 2011

How to convert iphone accelerometer raw data to degrees

Hello and Happy new year!!

Someone asked me yesterday how can we convert the iphone accelerometer outputs to degrees. Well, it's easy. We are going to use the function

CGFloat RadiansToDegrees(CGFloat radians) {return radians * 180/M_PI;};


and then, the only thing we need to do is

CGFloat angleXY=RadiansToDegrees(atan2(acceleration.y, acceleration.x));


For example, if we want to show this data in a UITextField called textXY

textXY.text=[NSString stringWithFormat:@"%f", angleXY];


Hope help!!

Friday, December 24, 2010

SCPPlugin Server certificate verification failed: certificate issued for a different hostname

Hi, Today I've had a problem trying to connect to my svn server. Using SCPPlugin on my MacBook I receive the next romantic message:
Server certificate verification failed: certificate issued for a different hostname...

What?? How can we fix this??

Nothing like using the terminal to solve these problems.

Go to Applications > Utilities > Terminal and make the checkout by hand:

svn co https://SERVER

[...]

Certificate information:
- Hostname: SERVER
- Valid: from Sat, 11 Dec 2010 13:22:57 GMT until Mon, 10 Jan 2011 13:22:57 GMT
- Issuer: blablaba
- Fingerprint: blablabla
(R)eject, accept (t)emporarily or accept (p)ermanently? p

[...]


And now we have our server certificate validated and working on SCPPlugin

Hope help!

Bye and Merry Christmas

Sergio

Monday, December 20, 2010

Connecting using phpMyAdmin to a remote database

phpMyAdmin allow us to connect to a remote database easily. The only thing we need is to edit the config.inc.php file. I suppose this file lives in the phpMyAdmin directory.

Editing this file, look for the array $cfg['Servers'] and copy it from $i++:


$i++;
$cfg['Servers'][$i]['host'] = 'localhost'; // MySQL hostname or IP address
$cfg['Servers'][$i]['port'] = ''; // MySQL port - leave blank for default port
$cfg['Servers'][$i]['socket'] = ''; // Path to the socket - leave blank for default socket
$cfg['Servers'][$i]['connect_type'] = 'tcp'; // How to connect to MySQL server ('tcp' or 'socket')
$cfg['Servers'][$i]['extension'] = 'mysql'; // The php MySQL extension to use ('mysql' or 'mysqli')
$cfg['Servers'][$i]['compress'] = FALSE; // Use compressed protocol for the MySQL connection
// (requires PHP >= 4.3.0)
$cfg['Servers'][$i]['hide_db'] = 'information_schema';

$cfg['Servers'][$i]['controluser'] = ''; // MySQL control user settings
// (this user must have read-only
$cfg['Servers'][$i]['controlpass'] = ''; // access to the "mysql/user"
// and "mysql/db" tables).
// The controluser is also
// used for all relational
// features (pmadb)
$cfg['Servers'][$i]['auth_type'] = 'http'; // Authentication method (config, http or cookie based)?
$cfg['Servers'][$i]['user'] = 'user'; // MySQL user
$cfg['Servers'][$i]['password'] = ''; // MySQL password (only needed
// with 'config' auth_type)
$cfg['Servers'][$i]['only_db'] = ''; // If set to a db-name, only
// this db is displayed in left frame
// It may also be an array of db-names, where sorting order is relevant.
$cfg['Servers'][$i]['verbose'] = ''; // Verbose name for this host - leave blank to show the hostname

$cfg['Servers'][$i]['pmadb'] = ''; // Database used for Relation, Bookmark and PDF Features
// (see scripts/create_tables.sql)
// - leave blank for no support
// DEFAULT: 'phpmyadmin'
$cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark'; // Bookmark table
// - leave blank for no bookmark support
// DEFAULT: 'pma_bookmark'
$cfg['Servers'][$i]['relation'] = 'pma_relation'; // table to describe the relation between links (see doc)
// - leave blank for no relation-links support
// DEFAULT: 'pma_relation'
$cfg['Servers'][$i]['table_info'] = 'pma_table_info'; // table to describe the display fields
// - leave blank for no display fields support
// DEFAULT: 'pma_table_info'
$cfg['Servers'][$i]['table_coords'] = 'pma_table_coords'; // table to describe the tables position for the PDF schema
// - leave blank for no PDF schema support
// DEFAULT: 'pma_table_coords'
$cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages'; // table to describe pages of relationpdf
// - leave blank if you don't want to use this
// DEFAULT: 'pma_pdf_pages'
$cfg['Servers'][$i]['column_info'] = 'pma_column_info'; // table to store column information
// - leave blank for no column comments/mime types
// DEFAULT: 'pma_column_info'
$cfg['Servers'][$i]['history'] = 'pma_history'; // table to store SQL history
// - leave blank for no SQL query history
// DEFAULT: 'pma_history'
$cfg['Servers'][$i]['verbose_check'] = TRUE; // set to FALSE if you know that your pma_* tables
// are up to date. This prevents compatibility
// checks and thereby increases performance.
$cfg['Servers'][$i]['AllowRoot'] = TRUE; // whether to allow root login
$cfg['Servers'][$i]['AllowDeny']['order'] // Host authentication order, leave blank to not use
= '';
$cfg['Servers'][$i]['AllowDeny']['rules'] // Host authentication rules, leave blank for defaults
= array();



Add your data to each fields and you are ready to connect remotely.

Hope help!

Tuesday, December 14, 2010

IntelliSense: #error directive: Please use the /MD switch for _AFXDLL builds

Hello,

This is my first problem for today. How can I fit it? Easy, I hope:

Go to Project Properties > C/C++ > Code Generation > Runtime Library and set to MD.

It works

Bye

Monday, November 22, 2010

PHP Fatal error: Allowed memory size ...

How can I fix this? Easy... If your MySQL (or other PHP based software) show this message you can increase the allowed memory size for PHP.

Edit the php.ini and modify
memory_limit = 75M ; Maximum amount of memory a script may consume (8MB)

Increase uploading file size for QUIX

It's not Quix but PHP configuration what we need to config.

Easy way is to create a new .haccess file in the root directory of quix and add the lines:


php_value upload_max_filesize 10M
php_value post_max_size 10M


Another option is to edit the php.ini

Bye!!

Tuesday, February 2, 2010

C# Changing Text font style (bold, color, family) in a Listbox or Combobox

My new question is how to set a new font type for a combobox or listbox in c sharp and... is easier than you are thinking.

First of all, we must set a new DrawMode Event for our Listbox

OurListBox.DrawMode = DrawMode.OwnerDrawFixed;
OurListBox.DrawItem += new DrawItemEventHandler(OurListBox1_DrawItem);

Now, when the Listbox is drawn, the application will call the function OurListBox1_DrawItem and is here when we change the font style.

private void OurListBox1_DrawItem (object sender, DrawItemEventArgs e)
{
e.DrawBackground();
e.Graphics.DrawString(OurListBox.Items[e.Index].ToString(), new Font("Microsoft Sans Serif", 8, FontStyle.Regular), Brushes.DarkBlue, e.Bounds);
e.DrawFocusRectangle();
}


and ... done it!, You will have yours list items in DarkBlue color.

Question? hehehe.

Greetings