Mar
15

Get the value of radio buttons with Prototype

In the Prototype javascript library, there’s a utility function, $F, which gets value of a form control.  It doesn’t work quite so well for Radio Buttons.

The following code does not work:

<input type="radio" name="myRadio" value="one"/>
<input type="radio" name="myRadio" value="two"/>
<input type="radio" name="myRadio" value="three"/>

<input type="button" onclick="alert($F('myRadio'))"/>

I created another function which gets you the value of the radio button:

function $RF(el) {
   return Form.getInputs($(el).form, 'radio', $(el).name).find(
     function (radioElement) {
      return radioElement.checked;
   }).value;
}

<input type="radio" name="myRadio" value="one"/>
<input type="radio" name="myRadio" value="two"/>
<input type="radio" name="myRadio" value="three"/>

<input type="button" onclick="alert($RF('myRadio'))"/>

Jan
13

Grep through sub-directories

Often times you want to search for a string pattern in all the files under a directory and its sub-directories.

Simply run this:
find . | xargs grep whatever

For example:
find . -name "*.txt" | xargs grep for

Output:
/cygdrive/c
[sohel@laptop] $ cat temp/post.txt
Time for an Upgrade.
It's about that time where your PC needs an upgrade. There was nothing wrong with my existing setup, but I figured, hey why not?

/cygdrive/c
[sohel@laptop] $ find . -name "*.txt" | xargs grep for
temp/post.txt:Time for an Upgrade.

Dec
07

Time for an Upgrade.

It’s about that time where your PC needs an upgrade.  There was nothing wrong with my existing setup, but I figured, hey why not?

Specs:

Motherboard: ASUS Sabertooth X58 LGA 1366 Intel X58
CPU: Intel Core i7-950 Bloomfield 3.06GHz
Memory: G.SKILL Ripjaws Series 8GB (2 x 4GB)
Power Supply: CORSAIR CMPSU-750TX 750 Watts
HDD: A-DATA  2.5" 64GB SATA II Internal Solid State Drive (SSD)
Video Card: ASUS GeForce GTX 470 (Fermi) 1280 MB

IMG_0650
Everything still in the box
IMG_0651
Existing parts gutted and taken out
IMG_0652
I need power!

IMG_0654
Motherload.
IMG_0656
IMG_0657
The beast that will make this thing tick.
IMG_0658
IMG_0659
Blam. Fitted.
IMG_0660
IMG_0661
So I hear you can remember a lot of things
IMG_0663
Almost there.
IMG_0664
Feed me.
IMG_0668
So you’re the reason behind all this?
IMG_0670
IMG_0671
Ready for the first test run.
IMG_0673
Success!

Nov
10

Free your iPhone (and iPod)

Often times you want to manage your music without iTunes.  There could be many reasons, one being that your iPhone is restricted to be used with one and only one computer.  There are many utilities out there that allow you to retrieve songs from your iPhone/iPod, but it’s hard to find one without having to pay for it or it being trial version with limitations.  I came across a free utility called SharePod which allowed me to do everything I needed without iTunes.

You can add and remove music, videos, playlists, and artwork on your iPod.

Download it now and see what you’re missing.

Oct
25

Follow Facebook friends on Twitter

If your Facebook friends are using Twitter, you can follow them by doing the following:

Import your Facebook contacts to Yahoo

  1. Create a Yahoo account if you don’t already have one
  2. Click on Contacts
  3. Click on Tools
  4. Click on Import
    yahoo-import
  5. Select Facebook
  6. A pop-up will appear, asking you if its Okay for facebook to share your contacts with Yahoo.  Click ‘Okay’
    yahoo-import2
  7. Your Facebook contacts will be downloaded and imported into your Yahoo account.
    yahoo-import3
    yahoo-import4

Import your Yahoo contacts to Twitter

  1. Log into Twitter and click ‘Find Friends
  2. Import your Yahoo contacts
    twitter-import
  3. When the pop-up appears, login to your Yahoo account and click on ‘Agree’ when prompted to authorize Twitter to access your contacts.
    twitter-import2
  4. Your contacts will be imported
    twitter-import3
  5. If your Yahoo/Facebook contacts are using Twitter, you will be able to follow them.
    twitter-import4

Oct
20

Top 10 Songs

These are some of the songs I’ve been listening to lately. They’re all Hip Hop and Rap, don’t hate.

1. Lil Jon – Throw it up

2. Pitbull – Hey Baby (Drop it to the Floor)

3. Kanye West – Runaway (Ft. Pusha T)

4. Usher – Hot Tottie (Ft. Jay Z)

5. Usher – OMG (Ft. Will.I.Am)

6. Yolanda Be Cool – We No Speak Americano

7. Chris Brown – Deuces (Ft. Tyga & Kevin McCall)

8. Rick Ross – Blowing Money Fast

9. Waka Flocka Flame – No Hands (Ft. Roscoe Dash)

10. The Party Boyz – Daddy Stroke

Oct
19

Developer Tools

I always wonder what kind of tools other software developers are using. These are some of my favorite tools (for Windows) I use on a day-to-day basis.

IntelliJ – Java IDE – It’s not free, but I prefer this over Eclipse for many different reasons. It has a complete set of tools and integrations with the most important modern technologies and frameworks, such as Spring and Hibernate — a must-have for effective Web and Java EE development.

NetBeans IDE – I use this as my C++ IDE. It is a free, open-source Integrated Development Environment for software developers. You get all the tools you need to create professional desktop, enterprise, web, and mobile applications with the Java language, C/C++, and even dynamic languages such as PHP, JavaScript, Groovy, and Ruby. NetBeans IDE is easy to install and use straight out of the box and runs on many platforms including Windows, Linux, Mac OS X and Solaris.

Toad – Database Development for Oracle. Again, it’s not free, but you wont find anything better. Some benefits are:

  • Understand your database environment through visual representations
  • Meet deadlines easily through automation and smooth workflows
  • Perform essential development and administration tasks from a single tool
  • Manage more than just Oracle with multi-platform querying and data modeling tools, available for use at no cost
  • Deploy high-quality applications that meet user requirements and perform reliably in production
  • Validate database code to ensure the best-possible performance
    Manage and share projects, templates, scripts and more with ease

Google Chrome Sorry Firefox, but Chrome has you beat. Chrome is designed to be fast in every possible way: It’s quick to start up from your desktop, loads web pages in a snap, and runs complex web applications fast. It also comes with many great web developer tools out of the box.

WinMerge is an Open Source differencing and merging tool for Windows. It can compare both folders and files, presenting differences in a visual text format that is easy to understand and handle.

UltraVNC is an open source application for the Microsoft Windows operating system that uses the VNC protocol to control another computer’s screen remotely. It bears a strong resemblance to RealVNC Free Edition, however in addition to remote control it adds various features, such as an encryption plugin to secure the client/server connection. It also supports file transfers, chat functionality and various authentication methods

vim-editor_logoGVim is a windows GUI version of ‘vi’. Nuff’ said.



Notepad++ is a free source code editor and Notepad replacement that supports several languages. Running in the MS Windows environment and based on the powerful editing component Scintilla, it’s written in C++ and uses pure Win32 API and STL which ensures a higher execution speed and smaller program size. By optimizing as many routines as possible without losing user friendliness.

Putty is a free implementation of Telnet and SSH for Windows and Unix platforms, along with an xterm terminal emulator



TurtoiseSVN is a free Subversion client, implemented as a Microsoft Windows shell extension. Must-have if you’re doing anything with Subversion.


FileZilla is a free, open source, cross-platform FTP software.



Internet Explorer Developer Toolbar for those of you stuck with supporting applications on IE, this is an add-on for Internet Explorer 6 and Internet Explorer 7 that aims to aid in design and debugging of web pages. It allows validating of CSS and HTML, previewing page layout at various resolutions, and also offers a ruler (measuring in pixels) to aid in positioning the elements. It allows viewing the source of the entire page, color coded for ease of navigation, or selected elements of it, as well as view the DOM source and the CSS selectors that are applied to the element. It also enables viewing the properties and styles of individual elements and also trace styles of elements to its declaration.

Maven is a software tool for project management and build automation. While primarily used for Java programming, it can also be used to build and manage projects written in C#, Ruby, Scala, and other languages. Maven serves a similar purpose as the Apache Ant tool, but it is based on different concepts and works in a profoundly different manner

Ant is a software tool for automating software build processes. It is similar to Make but is implemented using the Java language, requires the Java platform, and is best suited to building Java projects.

JIRA provides issue tracking and project tracking for software development teams to improve code quality and the speed of development.

Combining a clean, fast interface for capturing and organising issues with customisable workflows, OpenSocial dashboards and a pluggable integration framework, JIRA is the perfect fit at the centre of your development team.

FishEye unlocks Subversion, Git, Perforce, Clearcase, CVS, and Mercurial with real-time notifications of code changes plus web-based reporting, visualisation, search and code sharing.

Whether you’re coding, debugging, testing, refactoring, or just keeping an eye on the codebase, FishEye puts the info you need where you want it: JIRA issues, Bamboo builds, email/ RSS alerts, OpenSocial Dashboards or your IDE!

Hudson is a continuous integration tool written in Java, which runs in a servlet container, such as Apache Tomcat or the GlassFish application server. It supports SCM tools including CVS, Subversion, Git and Clearcase and can execute Apache Ant and Apache Maven based projects, as well as arbitrary shell scripts and Windows batch commands.

What are some of the tools that you use?

Oct
11

Backgrounds

Found myself tired of my current backgrounds, so I hopped over to deviantart.com and picked these up. Enjoy.

AeonFlux_by_Serial2305 Assassin__s_Creed_HD_PS3_by_TexStar05 Balance_Wallpaper_by_nxxos ceeb50531797f43ba25d18a6046ec3be Colony_47_by_Artush Designer__s_Room_2_0_by_K3nzuS Discovering_space2_by_Matkraken Ferrarri_F430_2008_01_1920x1200 For_A_Thousand_Years_by_vaporization golden_haze_by_tadp0l3-d2z4s65 four_seasons_wallpaper_by_Dawn42 Yoritsuki_wallpaper_by_HYBRIDWORKS Yoritsuki_wallpaper_Night_by_HYBRIDWORKS Island_Road_by_dobee King_by_Msch Sleepless_Nights_by_Skybase this____is____spartaaaaaa_by_woxys-d30k2o5

Mar
19

Google Chrome – The application failed to initialize properly (0xc0000005)

I’ve been using Google Chrome for quite some time now and really like it as my everyday browser.

Recently, however, I’ve been getting errors while starting it:

chrome_error
“The application failed to initialize properly (0xc0000005)”

There are several solutions to this.  I’ve only tested this one and it worked for me:

Solution 1:

Run Google Chrome with --no-sandbox

Right click on your shortcut, click on properties,

add “–no-sandbox” to the end of the target (i.e, my target looks like this: "C:Documents and SettingsmyusernameLocal SettingsApplication DataGoogleChromeApplicationchrome.exe" --no-sandbox)

Solution 2 (applicable if you have symantec installed)

Modify your registry as follows:

  • Navigate to HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesSysPlant
  • Open the Start DWORD
  • Change the value to 4

You might have to reboot after this.

Solution 3

May be due to winhttp.dll: http://techblissonline.com/google-chrome-crashed-winhttp-dll/

Oct
09

Configuring and Using JDBC Datasources on Tomcat 6 with JNDI

We are using Weblogic 9.2 in our development, testing, and production environments.  Its usually best to use the same application server when developing on your local machine, but it can eat up a lot of resources that your computer may not handle.

I’ve run into this problem before so I decided to use Tomcat 6.0.18 on my machine for testing locally.  The only thing I really had to worry about was using JNDI lookup to retrieve a DataSource for database connections.

I’ve used several references from the Tomcat documentation, but it wasn’t all too clear to me in the beginning.  This guide should walk you through step by step to configure and use JDBC DataSources on Tomcat 6 usign JNDI lookup.

I’ll be configuring a JDBC DataSource using the Oracle JDBC drivers.

Assuming you already have Tomcat installed and properly running, your directory structure should look like the following:

/bin
/conf
/lib
/logs
/temp
/webapps
/work

in the conf directory, you will see these files:

/conf
catalina.policy

catalina.properties

context.xml

logging.properties

server.xml

tomcat-users.xml

web.xml

You will need to modify the server.xml file

Inside the <GlobalNamingResources> block, you will need to add the following entry:

 <Resource name="jndi_name_goes_here" auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@db_host:db_port:db_sid"
username="user_id" password="pwd"/>

So, as an example, my entry looks like the following:

 <Resource name="jdbc/coast" auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@development_host:7000:coast"
username="coast" password="coast" maxActive="20" maxIdle="10"
maxWait="-1"/>

Since I am using Oracle’s JDBC drivers, I will need to add their jar file in the tomcat’s lib directory.
You can download it from here:
http://download.oracle.com/otn/utilities_drivers/jdbc/10204/ojdbc14.jar
or
http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/jdbc_10201.html

Next, assuming you already have a web application created, your directory structure should have these directories and files:

web_app_directory
    /WEB-INF
/WEB-INF/web.xml
/META-INF
/META-INF/context.xml

Next, you will need to add a META-INF directory to your web project.

Inside that META-INF directory, you will need to add a context.xml file.

Your context.xml file should look like the following:

<Context>

<ResourceLink name="jdbc/coast" global="jdbc/coast" type="javax.sql.DataSource" />

</Context>

Next, you will need to update the web.xml file in the WEB-INF folder.

You should add an entry in the end of the file before closing the <web-app> tag like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
...
...
<resource-ref>
<description>CoastDatasource</description>
<res-ref-name>jdbc/coast</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

</web-app>

You should now be able to retrieve the DataSource within your web application.

You can test your configuration by creating a small jsp with the following code:

<%@ page import="javax.naming.Context" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="javax.naming.InitialContext" %>
<%@ page import="javax.sql.DataSource" %>

<%

Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:/comp/env");
DataSource ds = (DataSource) envContext.lookup("jdbc/myoracle");
Connection conn = ds.getConnection();

%>

Older posts «