Iterate element using jQuery each

Leave a comment.


As a web developer or web design choose the right library is very important to speed up development process, there are many javascript tookit out there such as jQuery, prototype, dojo toolkit, etc. In here i will teach you some tips using jQuery each to iterate inside element. For example you want to store all of text inside li element to array. See script code bellow:
For example we have four list element that have a text. we want to get all of text store into array

<ul>
  <li>Juice Apel</li>
  <li>Juice Guava</li>
  <li>Juice Mango</li>
  <li>Juice Strawberry</li>
</ul>

There are two ways that have same result, you can choose as you like.
First way

var result = [];
jQuery.each( $('ul li'), function(index, val) {
  result.push( $(this).text() );
});
console.log( result.join('#') );

// output:
// Juice Apel#Juice Guava#Juice Mango#Juice Strawberry

Second way

var result = [];
$('ul li').each(function(index, val) {
  result.push( $(this).text() );
});
console.log( result.join('#') );

// output:
// Juice Apel#Juice Guava#Juice Mango#Juice Strawberry

Event if its has same result, but i suggest you to use first way. Because many expert developer suggest to use first way for speed performance reason.


Introduction to Go programming language

Leave a comment.


Web technology is growing faster than we think, as you can see that programming language is growing too. In years or maybe in month there’s new programming language out there. Here i will show you the new programming language that nowadays is popular, becoming a trend in web technology. That is Go also commonly reffered to as golang.

 

Go is an open source programming language that makes it easy to build simple, reliable and efficient software. It’s fast-compiled language, garbage-collected, concurrent systems programming language. It has following advantages:

Read more »


Installing Node.js in Mint and Archlinux

Leave a comment.


According to node.js site,node.js is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.

Nodejs is javascript that run on server side and it’s very good for built network application and realtime application. To install nodejs on ubuntu is very simple, open your favorite terminal and then type command as following below:

sudo apt-get install nodejs

If nodejs in official repository is not upto date you can get other unofficial in ppa. Just copy and paste this ppa repository address in your terminal:

sudo add-apt-repository ppa:chris-lea/node.js-legacy

If any confirmation from command, just press enter after that type sudo apt-get update and wait command until complete. There’s other ways to add repositoty but this way is not recommended. Create file inside folder /etc/apt/sources.list.d with name chris-lea.list and then copy and paste this code to that file:
deb http://ppa.launchpad.net/chris-lea/node.js-legacy/ubuntu precise main
deb-src http://ppa.launchpad.net/chris-lea/node.js-legacy/ubuntu precise main

Don’t forget to adjust your repository based on your linux mint version that you use. For example for version 17 has code name ‘trusty’, 16= saucy, 13= precise. For more detail you can open Linux Mint website.

For archlinux you can use pacman package manager or packer for aur repository, just type pacman -S nodejs or packer -S nodejs and wait until complete.

To test your installation is working, open terminal then type nodejs -v, if the result is same as below it mean your installation is success.

If you have any question, you can use comment box or contac me via email at smartgdi at gmail dot com. thanks for reading


Tortoisehg error saat di jalankan pada Archlinux

1 Comments.


Kejadian ini terjadi pada tanggal 4 Juli 2014, setelah saya upgrade archlinux saya. Berikut ini adalah screenshot erronya

Setelah browsing-browsing ternyata masalah ada pada library qscintilla pada pyhton2, solusinya adalah dengan mendowngrade libary dari versi 2.8.3-1 ke versi sebelumnya (2.8.1-2). Berikut perintah ini perintah untuk mendowngrade
pacman -U /var/cache/pacman/pkg/python2-qscintilla-2.8.1-2-x86_64.pkg.tar.xz.
dan Alhamdulillah aplikasi Tortoisehg kembali bisa jalan :)

Semoga bermanfaat.