query to get indexes in sqlsever database table

1) Summary

use DatabaseName
EXEC sys.sp_helpindex @objname = N'tablename'

2) Detail

SELECT top 100 
     TableName = t.name,
     IndexName = ind.name,
     IndexId = ind.index_id,
     ColumnId = ic.index_column_id,
     ColumnName = col.name,
     ind.*,
     ic.*,
     col.* 
FROM 
     sys.indexes ind 
INNER JOIN 
     sys.index_columns ic ON  ind.object_id = ic.object_id and ind.index_id = ic.index_id 
INNER JOIN 
     sys.columns col ON ic.object_id = col.object_id and ic.column_id = col.column_id 
INNER JOIN 
     sys.tables t ON ind.object_id = t.object_id 
WHERE 
	t.name = 'tablename'
     AND ind.is_primary_key = 0 
     AND ind.is_unique = 0 
     AND ind.is_unique_constraint = 0 
     AND t.is_ms_shipped = 0 

ORDER BY 
     t.name, ind.name, ind.index_id, ic.index_column_id

Tags: , ,

Coldfusion error – I/O Exception: peer not authenticated

I/O Exception: peer not authenticated

1

C:\ColdFusion8\runtime\jre\bin

Keytool -list -v -keystore C:\ColdFusion8\runtime\jre\lib\security\cacerts -storepass changeit

2

 

3

 

Keytool -importcert -v -alias mb-cert -file C:/data/mb.creativecrm.der -keystore C:\ColdFusion8\runtime\jre\lib\security\cacerts -storepass changeit

4 5

Restart CF service

6

DONE, no more error

7

Tags: , ,

error: insufficient permission for adding an object to repository database .git/objects

I was getting below error for the first time while committing the code to git

Deepaks-MacBook-Pro:cm deepakyadav$ git commit -m 'so far'
error: insufficient permission for adding an object to repository database .git/objects
error: insufficient permission for adding an object to repository database .git/objects
error: Error building trees

 

SOLUTION: run following CHOWN command in the same console path.

Deepaks-MacBook-Pro:cricmedia deepakyadav$ sudo chown -R deepakyadav .

So it will change the user[here ‘deepakyadav’ is the username with admin privileges] privilege. And this error should not come again.


 

Tags: , ,

Find web server root path in ColdFusion

This finds the root path that can be accessed from anywhere in the application folder.

<cfset replaceMe = replace(cgi.SCRIPT_NAME,'/','\','all')>
<Cfset webserverRoot = replace(cgi.CF_TEMPLATE_PATH,replaceMe,'') />
<cfdump var="#webserverRoot#">

 

 

Wifi reboot using automatic shell script on mac for irregular internet connection

I am running it on Mac OS X Yosemite 10.10.1

These days at my home I have a flaky internet connection. I am getting disconnected in every few minutes and had to turn off my wifi and switch it back on. Its very frustrating when I am watching a video, or downloading something. As it took a lot of time almost couple of minutes or more to get back to normal working again.

So to fix this temporarily I wrote below bash script and running it automatically at system boot. All it does is ping an ip every 5 seconds and if it fails to get a success response, it reboots the wifi on my mac. If it fails for 3 consecutive times then I am stoping this script. You can change to variable named ‘maxRebootTry’ according to your needs. Also you can limit of the number times of times you want to try ping by passing numeric count as an argument during execution time of the script. Example ./wifi.sh 100 , for 100 times ping. By default it is infinite

Step 1) Open Terminal

Step 2) sudo nano wifi.sh

Step 3) Copy & Paste below code. Then save(control+o -> enter) & exit (control+x)

maxPing=${1-0}

if [[ maxPing -ne 0 ]] ; then

        echo "Pinging $maxPing times "

else

        echo "Pinging unlimited times "

fi

#echo 'Begin ping'

#ping -i 5 8.8.8.8

((maxRebootTry=3))

((count=1))

while [ $count -ne 0 ] && [ $maxRebootTry -ne 0 ] ; do

        ping -c 1 8.8.8.8

        rc=$?

        echo "RESULT:$rc"

        if [[ $rc -eq 0 ]] ; then

                #say "good internet"

                ((maxRebootTry = 3))

                sleep 5

        else

                networksetup -setairportpower en0 off

                say "No internet connection. Trying wifi reboot"

                networksetup -setairportpower en0 on

                sleep 10

                say "wifi Reboot successful. Trying to connect again"

                ((maxRebootTry = maxRebootTry - 1))

        fi

        if [[ maxPing -ne 1 ]] ; then

                ((maxPing = maxPing - 1))

        else

                ((count = 0))

        fi

done

 

Step 4) Run it on terminal. Either pass argument for number of ping tries, or don’t pass anything for infinite pings

./wifi.sh 10

./wifi.sh

 

Step 5) Convert to Application (.app file) [Image 1]

Open Automater, New Document

Choose ‘Application’

Under Library -> Utilities -> click ‘Run Shell Script’ -> Either copy your code, or just write ./wifi.sh in the script option provided.

Save it as Application, and it would be save as .app file

Now, you can it like any other Mac application, by searching it in spotlight.

 

Step 6) Automation [Image 2]

Open Settings -> ‘User & Groups’ -> Current User -> Login Items

Click Add + and browse your .app.

Your application will now startup on its own upon your macbook reboot.

 

Step 7) Check it in status bar running successfully. Now your wifi will reboot itself if it needs to in case of lost packets. [Image 2]

 

 

Use Automater to convert shell script to application

Use Automater to convert shell script to application

2) startup mac program

 

 

 

 

Tags: , , , , , , ,

Two Factor Testing






Dreamweaver launch giving xml parsing fatal error

dreamweaverErrorMsg

I got the above error while launching my Adobe Dreamweaver CS5.5. This is coming because of corrupted  .txt  file that DM looks at startup. File: “C:\Users\dyadav\AppData\Roaming\Adobe\Dreamweaver CS5.5\en_US\Configuration\Workspace\current.txt”

browseThe text of file current.txt file should be “Designer.xml” but some how it was changed to “App Developer.xml” (most prob due to force reboot when DW got hanged). So I changed the text to “Designer.xml” and launched the DW again, and it worked this time !!

Tags: , , , ,

Adding JqGrid to Coldfusion 9 page

Download JQGrid from http://www.trirand.com/blog/?page_id=6

 

In test.cfm:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>

<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>

<link rel="stylesheet" href="jquery-uiGrid.css" />
<script src="grid.locale-en.js" type="text/javascript"></script>
<script src="jquery.jqGrid.min.js" type="text/javascript"></script>

<script type="text/javascript">
    $(document).ready(function(e) {

        jQuery("#domainUserGrid").jqGrid({
            url:'cfc/user.cfc?method=getTestUser',
            datatype: "json",
            height: "auto",
            colNames:['#','Username','Phone','Last Updated','Actions'],
            colModel:[
                {name:'userPhoneId_int',index:'userPhoneId_int', width:30},
                {name:'username_vch',index:'username_vch', width:160},
                {name:'phone_vch',index:'phone_vch', width:160},
                {name:'dateUpdated_dt',index:'dateUpdated_dt', width:100},
                {name:'actions',index:'actions', width:120}
            ],
            rowNum:25,
            pager: jQuery('#pager2'),
            rowList:[10,20,30,40],
            pager: '#pager2',
            sortname: 'update_dt',
            viewrecords: true,
            sortorder: "desc",
            caption:"Domain Users",

            jsonReader: {
              root: "ROWS", //our data
              page: "PAGE", //current page
              total: "TOTAL", //total pages
              records:"RECORDS", //total records
              cell: "CELL",
              id: "" //will default first column as ID
              }           
        });

    });
</script>

<table id="domainUserGrid"></table> <div id="pager2"></div>

 

In cfc/user.cfc

<cfcomponent>
    <cffunction name="getTestUser" access="remote" returnformat="plain">
        <cfargument name="page" required="yes">
        <cfargument name="rows" required="yes">
        <cfargument name="sidx" required="yes">
        <cfargument name="sord" required="yes">
        <cfargument name="domain" required="yes">

        <cfparam name="series" default="0">
        <cfset var dataout = '0' />
        <cfset var LOCALOUTPUT = {} />

        <cfquery name="getUsers" datasource="#application.ds#">
            SELECT userPhoneId_int,domainId_int,userid_int,insert_dt,update_dt,username_Vch,phone_vch
            FROM users
            <cfif sidx eq 'undefined' or sidx eq ''>
                order by update_dt desc, insert_dt desc
            <cfelse>
                order by #sidx# #sord#
            </cfif>
        </cfquery>

        <cfif getUsers.recordcount GT 0 AND rows GT 0>
            <cfset total_pages = ceiling(getUsers.recordcount/rows)>
        <cfelse>
            <cfset total_pages = 0>        
        </cfif>

        <cfset LOCALOUTPUT.PAGE = "#page#" />
        <cfset LOCALOUTPUT.TOTAL = "#total_pages#" />
        <cfset LOCALOUTPUT.RECORDS= #getUsers.RECORDCOUNT# />

        <cfset start = ((page-1)*rows)+1>
        <cfset end = page*rows>

        <cfset LOCALOUTPUT.rows = ArrayNew(1) />
        <cfset i = 1>
        <cfloop query="getUsers" startrow="#start#" endrow="#end#">

            <Cfset LOCALOUTPUT.ROWS[i] = StructNew() >
            <cfset LOCALOUTPUT.ROWS[i].ID = "#userPhoneId_int#" />
            <cfset dt = dateformat(update_dt,'mmm dd, yyyy') & ' ' & timeformat(update_dt,'HH:mm:ss')>
            <cfset LOCALOUTPUT.ROWS[i].cell = [#numberformat(i)#,"#username_vch#","#phone_vch#","#dt#","Actions here"] />

            <cfset i = i+1>
        </cfloop>

        <cfreturn  SerializeJSON(LOCALOUTPUT)>
    </cffunction>
</cfcomponent>

Tags: , ,

Minesweeper game

minesweeper game

minesweeper

 

DEMO

Tags: , , ,

Call webservice method with parameter in flex 4.5 mobile application

This section contains the declaration of webservice:

<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:WebService
id="getSummaryWeb"
wsdl="http://xyz.com/webservice/serv.cfc?wsdl"
fault="getSummary_faultHandler(event)"
result="getSummary_resultHandler(event)">

<s:operation name="getSummary">
<s:request xmlns="">
<site_id>{p.getProperty('p_sid')}</site_id>
<contact_id>{p.getProperty('p_uid')}</contact_id>
</s:request>
</s:operation>
</s:WebService>
</fx:Declarations>

You can call the above defined web-service at craetionComplete of mxml file using:

<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="Alert Summary"
creationComplete="getSummaryWeb.getSummary.send()">

“getSummary” is the name of method defined in the .cfc page.

Now to get the result of web-service you can use the following code:

public function getSummary_resultHandler(event:ResultEvent):void
{
summaryCollector = event.result as ArrayCollection;
}

Here summaryCollector is a variable of type ArrayCollection.

Tags: ,