Pages

Wednesday, October 30, 2013

Eclipse undelete option

Thanks god eclipse has its own undelete option !!!

I had a strange bug in eclipse : when creating sources folder or a new class while another folder is selected, the new folder is created on root of classpath…
Anyway, i deleted the wrong folder class that was created and all the tree containing this folder was erased !!!! ….. :(
A quick look in the trashcan, nothing…. Eclipse does not put deleted files in the system trashcan, my blood goes off my body…. one day of coding lost because of this small bug….
So i started to test several undelete softwares. 3 hours later of scanning, my old photos or zip files came up, but no as files…
While i was starting crying my dear as code, i tried a last google search « Eclipse undelete », and here is the awaiting miracle !!! There is an option available in Eclipse !! select a folder and right mouse menu select : « Restore from Local History«
Then appear the deleted files history and you can choose which file to restore.
My coding day is restored too :)
 
http://www.lecrabe.net/wordpress/?p=43

Thursday, December 23, 2010

HTML5 - canvas

HTML5 defines the <canvas> element as “a resolution-dependent bitmap canvas which can be used for rendering graphs, game graphics, or other visual images on the fly.” A canvas is a rectangle in your page where you can use JavaScript to draw anything you want.</canvas>

Basic <canvas>
supportIE*    7.0+   
Firefox    3.0+   
Safari    3.0+   
Chrome    3.0+   
Opera    10.0+   
iPhone    1.0+   
Android 1.0+

Wednesday, December 22, 2010

javascript bug : parseInt('08')

Writing a simple Javascript function to create a Date object from a 'yyyy-mm-dd' string I found a small, but important, issue with the parseInt function, used to transform strings to integers.

Both parseInt('08') and parseInt('09') return zero because the function tries to determine the correct base for the numerical system used. In Javascript numbers starting with zero are considered octal and there's no 08 or 09 in octal, hence the problem.

To fix this just add the second parameter for parseInt, the base to be used for the conversion. The correct calls should be parseInt('08', 10) and parseInt('09', 10).

Tuesday, December 21, 2010

PHP short-hand IF/Else

Any programmer will agree that the IF/ELSE statements are a fundamental part of any language. The basic syntax is pretty universal between languages but many dont realise that there is a shorthand version that allows switching to be done inline.

The syntax is simply statement ? if-true : if-false

$variable = (statement) ? "return if true" : "return if false";

Compared to

if(statement)
{
$variable = "return this if true";
}
else
{
$variable = "return this if false";
}

As you can see, you save a lot of coding by using this lightweight syntax for simple IF/ELSE statements. It can also be used inline within strings which is where I find the most benefit of using it. Here is an example that has a real world use for a simple output that changes between "there is 1 item", "there are X items", and "there are no items" using multiple statements.

$text = "There ". ($total==1 ? "is 1 item" : "are ".($total == 0 ? "no items" : "$total items") );

Compared to:

if($total==0)
{
$text = "There are no items";
}
else if($total==1)
{
$text = "There is 1 item";
}
else if($total > 0)
{
$text = "There are $total items";
}

Tuesday, December 14, 2010

My little Javascript class mzCalendar / wrote yesterday /

My little Javascript class mzCalendar / wrote yesterday /

My little Javascript class mzCalendar That displays calendar. Easy install and use.

demo : http://migli.net/mzCalendar/

javascript : http://migli.net/mzCalendar/mzCalendar.js

css :
<style>
*{ font-size:13px;}
#mzCalendar { position:fixed; border:5px solid #cccccc; background:#FFFFFF; font-size:12px; width:200px; padding:3px; display:none; z-index:100;}
#mzCalendar .month { width:40%; float:left; padding:3px;}
#mzCalendar .year { width:40%; text-align:right; float:right; padding:3px;}
#mzCalendar .cbody { clear:both;}
#mzCalendar .cbody td { text-align:center; width:15px;}
#mzCalendar .cbody a { color:#000000; text-decoration:none; display:block;}
#mzCalendar .cbody a:hover { text-decoration:underline; background:#CCCCCC;}
#mzCalendar .cbody .seld { background:#0099FF;}
#mzCalendar .cbody .vac { color:#FF0000;}
</style>


in html
<input type='text' value='2010-12-13' id='aa1' readonly><a href='javascript:{}' onclick='cal.show("aa1");'>click</a>

Saturday, December 11, 2010

Creating blog first time in my life

Creating blog first time in my life

My name is Munhzol. I'm from Mongolia. Today I'm creating a blog first time in my life.May be there is in my posts will many errors. lol. But it's OK. if anybody knows my errors please comment it where and why :).

I interested in web programming technologies such as php, mysql, javascript, ajax, html, css etc. And very interested in electronics, embeded systems.