Changin terminal editor

Publicado 25 octubre 2010 por brusmax
Categorías: Linux

Etiquetas: , ,

Last time I intalled git on my computer I had to use vi to commit every change, as Im not so good editing files width vi I opted for change the editor to nano, so to do that open a terminal and type this:

export EDITOR=nano

Where nano is the editor to use.

Including jQuery in WordPress (The Right Way)

Publicado 21 mayo 2010 por brusmax
Categorías: JavaScript, JQuery, Wordpress

Etiquetas: ,

There are many ways to include jquery on wordpress, there is a post here http://www.nosolocodigo.com/5-trucos-para-usar-jquery-con-wordpress that shows 5 sore of set jqeruery, but I use this way http://digwp.com/2009/06/including-jquery-in-wordpress-the-right-way/ allegedly this is the best form to do it.

Facebook Style Input Box

Publicado 19 abril 2010 por brusmax
Categorías: JavaScript, JQuery

Etiquetas: , , ,

This is a jQuery plugin to allow users to select multiple items from a predefined list, using autocompletion as they type to find each item. You may have seen a similar type of text entry when filling in the recipients field sending messages on facebook.

http://loopj.com/2009/04/25/jquery-plugin-tokenizing-autocomplete-text-entry/

How to change the system time from shell

Publicado 24 marzo 2010 por brusmax
Categorías: Linux, server

Some times we need to change the system time from shell cause we only have ssh access, so to do this we have first to have the shell access or open and the tipe this:

sudo date 032411002010.00

Where it means: March 24th 2010 11:00:00

The first 4 numbers are the month and the day (0324 – March 24th)

The follow 4 number are the time (1100  11:00 Hrs.)

The follow 4 number are the year (2010)

and the last 2 number are the seconds (00)

100 Essential Web Development Tools

Publicado 17 marzo 2010 por brusmax
Categorías: General, JavaScript, PHP, Web Developer Tools

Etiquetas: , , , , , , , , , ,

I found an exelent list that provide some helpul tools to web developers.

Here is the post.

http://www.noupe.com/tools/100-essential-web-development-tools.html

Install an SMTP serer on server linux (ubuntu)

Publicado 24 febrero 2010 por brusmax
Categorías: Apache, Linux, server

Etiquetas: ,

Its reaaly simple to do it, to send mails from our server (local or not) using postfix

Ok to do this open your terminal and type:

sudo apt-get install postfix

As you are using “sudo” you must set your admin password.

For further configuration settings, type the following into the terminal as a new command :

sudo dpkg-reconfigure postfix

That’s it.

To read more about it, click:  http://my.opera.com/Contrid/blog/show.dml/478684

How to detect what browser the user use

Publicado 24 febrero 2010 por brusmax
Categorías: JavaScript

Etiquetas: ,

There are many things to do this, Im going to show one way to do it width JavaScript. Here we have an example:

var FF=/a/[-1]=='a';
if(FF){
//codigo}
else {
//codigo alternativo}
Where :
//Firefox detector 2/3
FF=/a/[-1]=='a'
//Firefox 3
FF3=(function x(){})[-5]=='x'
//IE detector
IE='\v'=='v'
//Safari detector
Saf=/a/.__proto__=='//
//Chrome
Chr=/source/.test((/a/.toString+''))
//Opera
Op=/^function \(/.test([].sort)
And all together:
B=(function x(){})[-5]=='x'?'FF3':(function x(){})[-6]=='x'?'FF2':/a/[-1]=='a'?'FF':'\v'=='v'?IE':/a/.__proto__=='//'?'Saf':/s/.test(/a/.toString)?'Chr':/^function \(/.test([].sort)?'Op':'Unknown'
Read more: http://geektheplanet.net/1489/detectar-facilmente-el-navegador-con-javascript.xhtml#ixzz0gPTtXDO9

Including a css style from a plugin on wordpress

Publicado 30 enero 2010 por brusmax
Categorías: General, Wordpress

Etiquetas: ,

there are many ways to do it, but I will show just two of them.

The first way is doing the following:

Using the wp_print_styles tag:

add_action('wp_print_styles', 'add_my_stylesheet');
function add_my_stylesheet() {
 $myStyleUrl = WP_PLUGIN_URL . '/myPlugin/';
 $myStyleFile = WP_PLUGIN_DIR . 'style.css';
 if ( file_exists($myStyleFile) ) {
 wp_register_style('myStyleSheets', $myStyleUrl);
 wp_enqueue_style( 'myStyleSheets');
 }
 }

The second way is printing it on the header file.

add_action('wp_head', 'business_directory_css');
function business_directory_css(){
 global $bizdir_relative;
 echo '<link type="text/css" rel="stylesheet" href="'.get_option("siteurl") . '/wp-content/plugins/myplugin/mycssstyle.css'" />' . "\n";
}

I thing the second one is easier.

Validate if a URL exists width CURL and PHP

Publicado 30 enero 2010 por brusmax
Categorías: General, PHP, Web Developer Tools

Etiquetas: , ,

There are a function that I found in the php Manual, and it can help. To use it you must have installed curl.

Here the function:

<?php
function url_exists($url) {
 $url = curl_init();
 curl_setopt($url, CURLOPT_URL, $strURL);
 curl_setopt($url, CURLOPT_BINARYTRANSFER, 1);
 curl_setopt($url, CURLOPT_HEADERFUNCTION, 'curlHeaderCallback');
 curl_setopt($url, CURLOPT_FAILONERROR, 1); 

 curl_exec ($url); 

 $intReturnCode = curl_getinfo($url, CURLINFO_HTTP_CODE);
 curl_close ($url); 

 if ($intReturnCode != 200 && $intReturnCode != 302 && $intReturnCode != 304) {
 return false;
 }else{
 return true ;
 }
} 

//example :
if(url_exists("http://php.net/manual/en/book.curl.php")) {
 echo"The URL exists";
}else{
 echo"The URL doesnot exist";
}
?>

How to convert a xls into a SQL database

Publicado 30 enero 2010 por brusmax
Categorías: MySQL, PHP, Web Developer Tools

xls2mysql_1

xls2mysql_1

There are some times that it is necessary to upload a xls as a data base in sql, so to do this there are a powerful tool that allow us to migrate a xls file to a sql database.

The steeps are:

  1. Download the script done in php. (download code here: http://scripts.ringsworld.com/database-tools/xls2mysql/)
  2. Locate the script some somewehere into the server folder
  3. Execute the xls2mysql_step1.php file (doing this must show some image like the following displayed)
  4. Select the xls file in the “File Upload” tab (The file must have into the first row the names of the fields )
  5. After upload the file the script will show two new tabs, the first one width the caption “Data” that will display a table width the information, and the second one width the caption “Mysql” wiil show the query to create a new table (this table will be the same as the file was called).
  6. The last step is to copy and paste to execute the query and generate the table.
xls2mysql_2

xls2mysql_2

xls2mysql_3

xls2mysql_3


Seguir

Get every new post delivered to your Inbox.