Sunday, April 24, 2011

How to extract our stored procedure code/text definition on MS SQL Server

I had a very interesting situation last week when visited one of my customer. Situation was they host their application on a server at their US headquarter and it run a SQL Server 2005, while all developer engine at Jakarta using SQL 2008. We got an issue on application which resulted on wrong calculation, after some time analyze I found we need to investigate the stored procedure in used. But, big concern was none of developer have latest version of the stored procedure. Thus, we need to extract it from US Server.  It got weird when we able to connect to US Server but unable to iterate SQL Server 2005 entity though we logged in as database owner. Due to limited time, so I asked the developer to run an ad-hoc command to extract stored procedure definition from US Server. Response I got was “how to do so ?”


For some developer who already spoiled by luxury of Microsoft Tools, most of the time, ad-hoc command become a history, thus how SQL Server works and how to manage it on console mode become another legend.


On every SQL Server Database, system will create system table called sysobjects to store all objects within respective database, this table will store information about objectid, object name, object type, etc. Respective to that object, there is syscomments table to maintain comment or text definition of specific object, it was referenced to sysobject through … yes, objectid field.


Now how to get code definition of a stored procedure:

Traditionally we can use below command

 
select text 
from syscomments c
inner join sysobjects o on c.id=o.id
where o.name like 'your_sp_name'



But when it gave a big text, result will be truncated so it would be difficult for us to read it. Nah, there is a ad-hoc command already prepared by SQL Server to perform such task, it was called sp_helptext


So what we need to, is just type below command on console
 
sp_helptext 'your_sp_name'



And voilla, all the magic to extract code/text definition of stored procedure will be taken care with easy.

Friday, April 15, 2011

What is CAPTCHA ?

image As a Website owner you may find you're getting spam in your registration forms, blog and forum comment areas or in your email inbox. And although sometimes it may feel like you spend a lot of your time dealing with these annoyances, there are tools to help minimize or eliminate spambot issues. Many business are adding CAPTCHA codes to their sites in order to help combat this kind of spam.

A CAPTCHA is a program that protects against bots by generating and grading tests that humans can pass but current computer programs cannot. The term CAPTCHA is an acronym for "Completely Automated Public Turing test to tell Computers and Humans Apart," trademarked in 2000 by Luis von Ahn, Manuel Blum, Nicholas Hopper and John Langford of Carnegie Mellon University, who developed the first CAPTCHA.

A common type of CAPTCHA requires the user to type the letters of a distorted image, sometimes with the addition of an obscured sequence of letters or digits that appears on the screen. This is a simple problem for humans, but a very hard problem for computers that have to use character recognition.

CAPTCHA can be used to monitor and solve many spam-related problems like preventing comment spam in blogs, protecting Web site registration, protecting email addresses from Web scrapers looking to add to spamming lists, ensuring that only humans can vote in online polls, preventing dictionary attacks in password systems as well as stopping search engine bots from crawling unindexed sites.

On the official CAPTCHA Web site (captcha.net) you can download and install a free CAPTCHA code provided by the reCAPTCHA Project that can help with decreasing spam-related issues and enable you to focus on other aspects of your business. ReCAPTCHA also enables you install an audio component to the test, making it user-friendly for the visually-impaired as well.

Some advantages to this code is that is a Web service, which means that all the images are generated and graded by reCAPTCHA's servers and can automatically update whenever a security vulnerability is found. ReCAPTCHA also has an IP address filtering and detection system that flags down IP addreses that solve too many CAPTCHAs in a certain period of time.

Easy-to-install plugins are available for WordPress, MediaWiki, PHP, Perl, Python and other environments. The CAPTCHA code is free for personal as well as commercial Web sites, but if you wish to install a non-branded code, you can purchase it for $160 per year

Resource:
Official CAPTCHA Website
Google ReCAPTCHA Project
http://www.thewhir.com/article-central/Working_With_CAPTCHA

Thursday, April 14, 2011

Best android tablet on market

image If you looking for a table but non an Apple-Fans or perhaps with a very tight budget on hand, then Android is the way to go. For a year back, many manufacturer decided to be contender on Android war, either on phone device or on table device. This competition is good for us as customer where we have much option to evaluate on, but also little bit maze for person who don’t want to spend some of their time to review, wrong information may lead them to wrong purchase of Android tablet. Well, lucky for them if they read this post because here we would like to show them best android tablet available on market.

So which tablets are the most tempting ? let’s find out

Monday, January 24, 2011

There is no foreach in JavaScript, use for … in instead

Programmer should be familiar with command foreach, which function is to iterate item within array or collection. This command normally available on most language, vb, php, c, java. Unfortunately, there is no foreach on JavaScript, and I just notice that until few minutes writing this post. After some research and reading over the javascript manual, I found that for … in is replacement for foreach

for … in

This command basically will iterate any object within an array, but instead refer to it’s collection object this command would pass only the key for collection object.

Syntax:

for (variable in object)
statement
Example

Please pay more attention on bolded italic text


child_cities=states[selected_state];
for(var cityid in child_cities)
{
ddl_city.options.length++;
ddl_city.options[ddl_city.options.length-1].text=
child_cities[cityid].description;
ddl_city.options[ddl_city.options.length-1].value=
child_cities[cityid].cityid;
}

Monday, January 17, 2011

How to opt-in our autoresponder subscriber and run other code simultaneously

 

 

 

 

 

 

To support one of my internet business I decided to use autoresponder service, unfortunately I was not dare enough to invest lots money for Aweber or GetResponse, 2 names listed as top leader on autoresponder business. So I decide to use cheap one, and money does matter. This cheap one didn’t give capability to do opt-in other than using their form, which is bad, because I also need to capture user information on my own database.

So, what I did:



1. Record my user information into database


2. Pass this information into HTML forms that  mimic opt-in form
3. Auto submit the form

It work fine for me.



The code itself is very simple as below, I use PHP and I assume we all already know how to insert into database, redirect and pass information to another form.

 



I use “display:none” to hide opt-in form, so forwarding process become seamless

   1:  <div style="display:none">


   2:  <form class='subscription_form' id='subscription_form' name="subscription_form" method='POST' action='####FORM_POST_URL####'>


   3:  <div align='center'><center>


   4:  <p>Full name<br><input type='text' name='full_name' size='20' value='<?php echo $name; ?>'></p>


   5:  </center></div>


   6:  <div align='center'><center>


   7:  <p>E-mail address<br><input type='text' name='email' size='20' value='<?php echo $email; ?>'></p>


   8:  </center></div>


   9:  <div align='center'><center>


  10:  <p>Phone #1<br><input type='text' name='phone1' size='20' value='<?php echo $phone; ?>'></p>


  11:  </center></div>


  12:  <input type='hidden' name='capitals' value='1'>


  13:  <input type='hidden' name='subscription_type' value='E'><div align='center'><center>


  14:  <p><input type='submit' value='Go »'></p>


  15:  </center></div>


  16:  <input type='hidden' name='id' value='5250'>


  17:  <input type='hidden' name='full_name_man' value='1'>


  18:  <input type='hidden' name='phone1_man' value='1'>


  19:  </form>


  20:  <div>


  21:   


  22:  </div>


  23:   


  24:  <script language="javascript" type="text/javascript">


  25:   


  26:  function init_form()


  27:  {


  28:      document.forms["subscription_form"].submit();


  29:  }


  30:   


  31:  window.onload=init_form;


  32:   


  33:  </script>


Wednesday, January 5, 2011

K2, a workflow and business process management on Microsoft Platform

image Few weeks back, I was lucky to experienced training for K2, a business process management software released by SourceCode Inc. There were 3 classes I attended, K2 Fundamental, K2 Integration and K2 API Programming.

K2 offers product to help increase business efficiency and simplify work. It basically synergize both technical and non-technical by converting business process to software programming through a visual block diagram. K2 Visual Tools allow people to automate process and streamline operations

Good things I like about this BPM is its capability to deal with many data resource and populate them all into one single virtual storage called as SmartObject. It also provide seamless integration with Sharepoint, which is good, especially for a corporate who already invest much on Microsoft Platform.

Tuesday, June 9, 2009

Copy code as HTML on Visual Studio, easy way to copy code on blogspot

I just notice that blogspot has limited capability on doing blog for programming code. Copy and paste from word also won't work properly as blogspot will not tolerate some whitespace character generated by Word. Luckily, on the net I found something that can address this issue.

Guy Burstein, provide a link to Microsoft Visual Studio AddIns that will allow us to copy any code that we highlight within Visual Studio and paste it automatically as HTML code. This will be helpfull lot on writing a code blog on blogspot, eventough we have to use manual HTML code still and it's exclusively to Visual Studio :)

So, here are steps to doing this:

1. Obtain AddIns here

2. Extract it to your Visual Studio AddIns folder, it's should be under MyDocuments\Visual Studio 2008\Addins, if you couldn't find AddIns folder, then create new one

3. Open Visual Studio, click on Tools -> AddIn Manager


4. AddIn manager dialog will be opened, select to activate "Copy as HTML" AddIn


5. Now, you can select any code and when do right click, "Copy as HTML" will be shown

Below is the result :)


  195 Public ReadOnly Property Email() As String


  196             Get


  197                 Dim daUser As New UserTableAdapter


  198                 Dim ret As String = ""


  199                 Dim users() As String = {}


  200                 Dim i As Integer = 0


  201 


  202                 For Each row As SecurityApprovalRow In Me.Rows


  203                     If Array.IndexOf(users, row.UserId) < 0 Then


  204                         Array.Resize(users, i + 1)


  205                         users(i) = row.User.Email


  206                         i += 1


  207                     End If


  208                 Next


  209                 Return IIf(users.Length = 0, "", String.Join(";", users))


  210             End Get


  211         End Property





Nice isn't ? Try it, code with smile :)