The goal of a reset stylesheet is to reduce browser inconsistencies in things like default line heights, margins and font sizes of headings, and so on.

The reset styles given here are intentionally very generic. There isn’t any default color or background set for the body element, for example. I don’t particularly recommend that you just use this in its unaltered state in your own projects. It should be tweaked, edited, extended, and otherwise tuned to match your specific reset baseline. Fill in your preferred colors for the page, links, and so on.

Continue reading

Some said that you cannot centre floated elements but this is not quite true. It’s true that usually you can only float left or float right but if you have a group of buttons (for example it is menu) and you want them to be fluid in width then it would be nice to have them all float in the centre of the page. There is no problem if the floats have a width because you can then ascertain the main parents width and use margin:auto to center the whole block. However that means that the floats cannot be a fluid width (i.e. shrinkwrap their content) or you would have to class each individual element and apply a different width to each which is a little unsatisfactory.

Continue reading

At grub-boot loader screen select Recovery mode the version of the kernel that you wish to boot and type e for edit. Select the line that starts with kernel and type e to edit the line.

Go to the end of the line and type init=/bin/bash as a separate one word (press the spacebar and then type init=/bin/bash). Press enter key to exit edit mode.

Back at the GRUB screen, type b to boot into single user mode. This causes the system to boot the kernel and run /bin/bash instead of its standard init. This will allow us gain root privileges (w/o password) and a root shell.

If you wanna reset root password remount paritions
Code:
mount -rw -o remount /
Setup root password

Code:
passwd

Today I found very usefull function, witch let to remove (disable) menu in wordpress admin. Its remove_menu_page( $menu_slug ) and remove_submenu_page( $menu_slug, $submenu_slug ).

It’s easy to remove menu entries and it is not necessary anymore to edit wordpress core. This is a small example, where I removed the entries to the comments and the submenu-page discussion.

Copy this example to function.php, and you will see, that it work.

function remove_admin_menu () {
	
		remove_menu_page( 'edit-comments.php' );
		remove_menu_page( 'link-manager.php' );
		remove_menu_page( 'tools.php' );
		remove_submenu_page( 'options-general.php', 'options-discussion.php' );
	
}
add_action( 'admin_menu', 'remove_admin_menu' );

This function will disable comments, links, ant tools menu.

Yesterday I had a task make stream images from ip camera. IP camera always put images to the same directory with same image name. This is a source code, whick can do this.

var tick=0;
image=new Image();
reload = new Date();
reload = reload.getTime();
image.src="http://your_domain.lt/camera/image.jpg?nocache="+reload;

function refreshCam()
{
tick++;
if(tick>3){restart=1;} else {restart=0;}
if(image.complete)
{
tick=0;
document.images["webcam"].src = image.src;
image=new Image();
reload = new Date();
reload = reload.getTime();
window.status = "";
image.src="http://your_domain.lt/camera/image.jpg?nocache="+reload;
}
if(restart)
{
tick=0;
image=new Image();
reload = new Date();
reload = reload.getTime();
window.status = "";
image.src="http://your_domain.lt/camera/image.jpg?nocache="+reload;
}
window.status = window.status + ".";
setTimeout("refreshCam()", 1000);
}
refreshCam();

And this is html code for this script


<IMG NAME="webcam" SRC="hhttp://your_domain.lt/camera/image.jpg" BORDER=0/>

This script refresh image once in a second. If you want to change time, you can do it in function setTimout(). 1000 is one second.

I hope, it will help for someone. 🙂

Today I needed to create link with anchor. When I pushed it, it opens new page and add class to div. The source code is:

var class= window.location.href.slice(window.location.href.indexOf('#') + 1).split('#');
if(class){
jQuery('.testimonial_cont').find('.'+class).show('slow');
jQuery('html,body').animate({scrollTop: jQuery('.testimonial_cont').find('.'+class).parent().offset().top},'slow');
}

Of course you can change slow to normal or fast or even a int in milliseconds.

I hope it will help for someone.

Some days ago I have a problem with my server and all my innodb tables were locked. And now I want to tell, how I tried to repair these tables.

First of all, I tried to do force recovery. In mysql config file enable force recovery. Set innodb_force_recovery = 1 and try to do mysqldump. If it not work, try to increase innodb_force_recovery value to 6. Default innodb_force_recovery value is 0. After you change innodb_force_recovery value, restart mysql.

Continue reading

With WordPress, you have the ability to create a network of sites (Multisite). This article is instructions for creating a network (multiple sites).

  1. First of all if you are running not fresh wordpress system, make back up off all you data.
  2. Open your config.php file and paste this above where it says /* That's all, stop editing! Happy blogging. */:
    <define('WP_ALLOW_MULTISITE', true);

    This allow to use multiple sites in your wordpress.

  3. Now install a network. Go to Administration > Tools > Network. Enter all required data ant press install.
    • Back up your old wp-config.php and .htaccess files.
    • Create blogs.dir directory in folder wp-content/
    • Add extra lines to your wp-config.php and replace your .htaccess file rules with new once. These rules are dinamically generated on your network configuration page.
    • Now log in again to system.

More information about this you can find in http://codex.wordpress.org/Create_A_Network.

To add class to wordpress wysiwyg editor copy this php code to your theme function.php file

if ( ! function_exists('tdav_css') ) {
	function tdav_css($wp) {
		$wp .= ',' .get_bloginfo('stylesheet_directory') . '/style_css.css';
	return $wp;
	}
}
add_filter( 'mce_css', 'tdav_css' );

Here you add new style file. In this file create your new css classes. Now go to wysiwyg editor and there you will see your created classes. Use them for table or links. 🙂

Sometimes we need to get depth of posts or pages in wordpress. Now you can do it easy with function


function getDepth($id = '', $depth = '', $i = 0)
{
 global $wpdb;
 global $post;
 if($depth == '')
 {
 if(is_page())
 {
 if($id == '')
 {
 $id = $post->ID;
 }
 $depth = $wpdb->get_var("SELECT post_parent FROM $wpdb->posts WHERE ID = '".$id."'");
 return getDepth($id, $depth, $i);
 }
 }
 elseif($depth == "0")
 {
 return $i;
 }
 else
 {
 $depth = $wpdb->get_var("SELECT post_parent FROM $wpdb->posts WHERE ID = '".$depth."'");
 $i++;
 return getDepth($id, $depth, $i);
 }
}

Copy function getDepth() in your function.php file. Call it from your template, for example <?php echo getDepth($post_ID);?>

and it will return your post depth in your site.

Try, I hope it will help you.