CSS Groups in E-texteditor

7 Jun

Press CTRL+SHIFT+B, open CSS folder then CSS language (with a black L on it, usually is last). Go to line 286 and find this:

"foldingStopMarker" : "(?<!\\*)\\*\\*/|^\\s*\\}",
"comment" : "",
"foldingStartMarker" : "/\\*\\*(?!\\*)|\\{\\s*($|/\\*(?!.*?\\*/.*\\S))",

Replace with this:

   "foldingStopMarker" : "(?<!\\*)\\*\\*/|^\\s*\\}|\/*\\s*@end\\s*\\*\/",
   "comment" : "",
   "foldingStartMarker" : "/\\*\\*(?!\\*)|\\{\\s*($|/\\*(?!.*?\\*/.*\\S))|\/\\*\\s*@group\\s*.*\\s*\\*\/",

Without grouping:

CSS Groups in E-texteditor

With grouping:

CSS Group in E-texteditor

Thanks to Chris Coyier.

Tags: , , Comments (2)

Bookmark this article!

Del.icio.usDiggStumbleUponFurlRedditTechnorati

SlashDotWindows LiveYahooGoogleFacebookBlogLines

Windows Vista and Microsoft mices

13 May

Until two months ago I had a Microsoft Laser 6000. I also runned Microsoft Vista. Hilarious (or not), two MS products doesn’t work together. Or not in the first place.

On some applications, the scroll from the mouse was choppy as hell and kinda impossible to use. I founded two application: winamp and e-texteditor. If winamp is not a big deal (because i use foobar), the real problem was my editor. After few searches on google, i found this solution:

  1. I installed the driver (intellipoint);
  2. Go to start -> run -> msconfig -> startup tab -> find and uncheck ipoint.exe;
  3. And finally, restart your computer

A real pain in the ass was when I wanted to change scrolling speed. I used a system tweaker and change settings from there. After that, restart and saw if is fine. Usually, 3-4 lines for scroll was great.

Few months after, I changed position of my computer and i had to unplug all wires (and trust me, i have A LOT of wires there). Of course, when I plugged all things back, i didn’t put the mouse receiver in the same USB port and it doesn’t worked well. I guess the same problem you will have if you have a notebook, then be sure you plug in the mouse in the very same usb port, because all things will be messed up. Solution? Put the receiver in the same port or redo all settings. I always picked first.

Tags: , , Comments (0)

Bookmark this article!

Del.icio.usDiggStumbleUponFurlRedditTechnorati

SlashDotWindows LiveYahooGoogleFacebookBlogLines

How do you format your code?

28 Nov

I’ve been asked few times how do i format my code. I try to stick to a easy to read and understand style. Sometimes i do, sometimes i don’t. Let’s talk first about those times i do :D

CSS Code

Each child is indented with a tab. So, i have this style:

1
2
3
4
5
6
7
8
9
#header {
 
}
	#search {
 
	}
		#search button {
 
		}

When you read only CSS you know that #header is the parent, #search is his child and the parent for button. Easy to read, easy to understand, right? :P

I try to avoid code like:

#parent #another_parent #header #search button { }

Because is kinda bogus.

I saw some guys who wrote their code on single line, without any indentation. Even if you have a less KB file, the result is hard to read and edit. Even though, i use very rarely one line code when i have to add one-two rule to a selector ( something like .element { color:red } ).

HTML Code

Actually… Somehow, i have same rule here: every child have a one tab indent:

1
2
3
4
5
<div id="header">
	<form action="" method="get" class="search">
		<button type="submit">Button</button>
	</form><!--/.search-->
</div><!-- /header-->

As an extra info: when i have large blocks of code (div, forms), on closing tag i add a comment with the id or class name: if the block has a class, the closing comment is /.class name and if is an id /id name

Again, easy to read and to maintain, especially when you reuse some of your code.

Javascript/jQuery Code

Well.. Probably is already clear enough how do i do:

1
2
3
4
5
6
7
8
9
10
11
function function_name() {
	var someVar = 1;
	if( someVar === 1 ) {
		alert('someVar is 1!');
		for(i=0;i<10;i++){
			alert(i);
		}
	} else {
		alert(':(');
	}
};//function_name

Conclusion

The main keywords are: indent and comments. You don’t have to overuse indent, because the code will be impossible/hard to read. Also, don’t over-comment your code. Don’t comment the obvious :

var foo = 'bar'; // the 'foo' get 'bar' value

Well.. I can’t say nothing else but „happy coding!”.

Tags: , Comments (6)

Bookmark this article!

Del.icio.usDiggStumbleUponFurlRedditTechnorati

SlashDotWindows LiveYahooGoogleFacebookBlogLines

A nice sortable trick (jQuery UI)

20 Nov

On a recent project i had to use sortable a LOT. I mean over 3-4 different sortable on page. So, how i manage to avoid heavy code?

One function to rule them all:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$('.sortable').each(function(){
	var _t = $(this);
	_t.sortable({
		handle:'.move',
		items:'dd',
		update:function(){
			$.ajax({
				type: "POST",
				url: $(this).find('a.move:eq(0)').attr('href'),
				data: _t.sortable('serialize'),
				cache: false
			});
		}
	});
});

The HTML markup (for two sortables) is this:

1
2
3
4
5
6
7
8
9
10
<dl class="sortable">
	<dd id="sotableEl1-1"><a href="updateUrl.php?id=sortableID-1" class="move">move</a></dd>
	<dd id="sotableEl1-2"><a href="updateUrl.php?id=sortableID-1" class="move">move</a></dd>
	<dd id="sotableEl1-3"><a href="updateUrl.php?id=sortableID-1" class="move">move</a></dd>
</dl>
<dl class="sortable">
	<dd id="sotableEl2-1"><a href="updateUrl.php?id=sortableID-2" class="move">move</a></dd>
	<dd id="sotableEl2-2"><a href="updateUrl.php?id=sortableID-2" class="move">move</a></dd>
	<dd id="sotableEl2-3"><a href="updateUrl.php?id=sortableID-2" class="move">move</a></dd>
</dl>

This means that you don’t need to use an ID for each sortable. Instead, you add the id to the update URL, on MOVE handler (which MUST be a link). I think this is pretty simple and useful trick.

Tags: , Comments (1)

Bookmark this article!

Del.icio.usDiggStumbleUponFurlRedditTechnorati

SlashDotWindows LiveYahooGoogleFacebookBlogLines