Anyone can comment, so leave your views

Wednesday, February 25, 2009

Java Apache releasing new HttpComponents

http://hc.apache.org improved library and better code. bug fixes over earlier versions. but its a new set of packages so cannot port directly. but worth the time as its better than the earlier blokes. Quick Start Enjoy!

HttpComponents is used to make requests to a page web page as get/ post. site scraping etc. Contact us for a solution Sel2In

Monday, February 23, 2009

Low-Tech Fixes for High-Tech Problems

Dry Ink Cartridge

If your printer's ink cartridge runs dry near the end of an important print job, remove the cartridge and run a hair dryer on it for two to three minutes. Then place the cartridge back into the printer and try again while it is still warm.

"The heat from the hair dryer heats the thick ink, and helps it to flow through the tiny nozzles in the cartridge," says Alex Cox, a software engineer in Seattle. "When the cartridge is almost dead, those nozzles are often nearly clogged with dried ink, so helping the ink to flow will let more ink out of the nozzles." The hair dryer trick can squeeze a few more pages out of a cartridge after the printer declares it is empty.

Remote Car Key

Suppose your remote car door opener does not have the range to reach your car across the parking lot. Hold the metal key part of your key fob against your chin, then push the unlock button. The trick turns your head into an antenna, says Tim Pozar, a Silicon Valley radio engineer.

Mr. Pozar explains, "You are capacitively coupling the fob to your head. With all the fluids in your head it ends up being a nice conductor. Not a great one, but it works." Using your head can extend the key's wireless range by a few car lengths.

Credit Card wont swipe

...he reaches beneath the counter for a black plastic bag. He wraps one layer of the plastic around the card and swipes it again. Success. The sale is rung up. "I don't know how it works, it just does," says Mr. Azar, who learned the trick years ago from another clerk. Verifone, the company that makes the store's card reader, would not confirm or deny that the plastic bag trick works. But it's one of many low-tech fixes for high-tech failures that people without engineering degrees have discovered, often out of desperation, and shared.

http://www.nytimes.com/2009/02/19/technology/personaltech/19basics.html?_r=2&pagewanted=1&no_interstitial

Tuesday, January 13, 2009

Java HTTP Client 4 beta2

SOLUTION
 
TO :
 
cannot determine the required jar files to compile samples/ own files
 
example org.apache.http.examples.client.ClientFormLogin
 
used
 
set CLASSPATH=P:\j\samples\httpClient\examples;j:\j\j5\h;P:\j\e\mysql.jar;P:\j\e\commons-logging-api-1.1.1.jar;P:\j\e\commons-logging-1.1.1.jar;P:\j\e\4\httpmime-4.0-beta2.jar;P:\j\e\4\httpclient-4.0-beta2.jar;P:\j\e\4\h\e\4\httpcore-4.0-beta3.jar;P:\j\e\4\httpcore-nio-4.0-beta3.jar
 
but still needs org.apache.http.*; ... where are these jars? a quick start guide / link to all jars for one version would help
 
- only known workaround - go back to old version 3.1
 

Regards
Tushar Kapila
santaletternow.com     http://sel2in.com


www.worldcommunitygrid.org Volunteer computer Cancer cures
www.thehungersite.com , and www.bhookh.com feed hungry , its free. www.ecologyfund.com
Please add these to your start-up how to: http://tusharkapila.blogspot.com/2008/05/s.html

Tuesday, November 25, 2008

Select Files & Folders: C# dotnet project excerpts

I recently had to do a MS Visual Studio DotNet C# project to mimic the back up tab of the Backup utility (attached image)
 
Two sites that helped : http://www.tangiblesoftwaresolutions.com/ and http://www.infragistics.com/ (tree view, over riding how a control is to be drawn, native support for 3 states of check boxes)
 
 
Interesting part is how it has to select parent nodes and gray them when you select a node whose parent/ grand parents are not selected.
 
Here is my altervative to using a image list and instead caching a few images
 
using System;
using System.Threading;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
using System.Collections.Generic;
 
using System.Data;
 
using System.Text;
using Infragistics.Win;
 
//using Infragistics.Win.UltraWinTree;
using Icons2;
 
using Infragistics.Win.UltraWinListView;
using Infragistics.Win.UltraWinTree;
using Infragistics.Shared.Serialization;
using FldrSel.draw;
using System.Runtime.InteropServices;
 
namespace Icons2
{
    /**
    * a holder for an icon and its ID
    * not required in all cases
    */
    public class IconInf
    {
        public Icon theIcon;
        public int id;
    }
    [StructLayout(LayoutKind.Sequential)]
    public struct SHFILEINFO
    {
        public IntPtr hIcon;
        public IntPtr iIcon;
        public uint dwAttributes;
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
        public string szDisplayName;
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
        public string szTypeName;
    };
 
    class Win32
    {
        public const uint SHGFI_ICON = 0x100;
        public const uint SHGFI_LARGEICON = 0x0; // 'Large icon
        public const uint SHGFI_SMALLICON = 0x1; // 'Small icon
 
        [DllImport("shell32.dll")]
        public static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, uint cbSizeFileInfo, uint uFlags);
    }
   
    public class Othr
    {
        private struct SHFILEINFO
        {
            public IntPtr hIcon; // : icon
            public int iIcon; // : icondex
            public int dwAttributes; // : SFGAO_ flags
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
            public string szDisplayName;
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
            public string szTypeName;
        }
 
        [System.Runtime.InteropServices.DllImport("shell32.dll", EntryPoint = "SHGetFileInfo", ExactSpelling = false, CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)]
        private static extern IntPtr SHGetFileInfo(string pszPath, int dwFileAttributes, ref SHFILEINFO psfi, int cbFileInfo, int uFlags);
 
        private const int SHGFI_ICON = 0X100;
        private const int SHGFI_SMALLICON = 0X1;
        private const int SHGFI_LARGEICON = 0X0; // Large icon
  
        public const string FOLDER_STR = "[folder]";
        public const string DRIVE_STR = "[folder]";
        Dictionary<string, IconInf> icons = new Dictionary<string, IconInf>();
 
        public Othr()
        {
        }
        public void init(){
            string sExtn = "txt";
            if (!icons.ContainsKey(sExtn))
            {
 
                DefaultIcon di = new DefaultIcon();
                IconInf oIconInf = new IconInf();
                oIconInf.theIcon = di.GetIcon(sExtn);
                oIconInf.id = icons.Count;
                icons.Add(sExtn, oIconInf);
            }
        }
 

        public IconInf getIcon(string sFileName)
        {
            return getIcon2(sFileName);
        }
        private IconInf getIcon2(string FileName)
        {
            lock (icons)
            {
                if (icons.Count > 1100)
                {
                    System.Collections.ArrayList keys = new System.Collections.ArrayList(icons.Keys);
                    for (int i = 700; i < 800; i++)//remove from the middle, hopefully they are less used
                    {                      
                        icons.Remove(keys[i].ToString());
                       
                    }
                    init();//reinit
 
                }
            }
           
            System.Drawing.Icon myIcon = null;
 

            IntPtr hImgSmall = default(IntPtr); //The handle to the system image list.
            IntPtr hImgLarge = default(IntPtr);
            string sExtn = null;
            sExtn = "txt";
 
 
 
            try
            {
               
                //FileName = "d:\Dev"
                if (!System.IO.Directory.Exists(FileName))
                {
                    sExtn = FileName.Substring((FileName.LastIndexOf(".") + 1));
                }
                else
                {
                    sExtn = FileName;
                }
                if (icons.ContainsKey(FileName))
                {
                    sExtn = FileName;
                }
                else if (icons.ContainsKey(sExtn))
                {
                    //do nothing
                }
                else
                {
                    DefaultIcon di = new DefaultIcon();
                    IconInf oIconInf =  new IconInf();
                    oIconInf.theIcon = di.GetIcon(sExtn);
                    oIconInf.id = icons.Count;
                    icons.Add(sExtn, oIconInf);
 
                }
 
            }
            catch (Exception ex)
            {
 
                try
                {
                    SHFILEINFO shinfo = new SHFILEINFO();
                    shinfo = new SHFILEINFO();
                    hImgSmall = SHGetFileInfo(FileName, 0, ref shinfo, Marshal.SizeOf(shinfo), SHGFI_ICON | SHGFI_SMALLICON);
                    myIcon = System.Drawing.Icon.FromHandle(shinfo.hIcon);
                    //icons[sExtn] = myIcon;
                   
                    IconInf oIconInf = new IconInf();
                    oIconInf.theIcon = myIcon;
                    oIconInf.id = icons.Count;
                    icons.Add(sExtn, oIconInf);
                }
                catch (Exception ex2)
                {
                    //default
                    sExtn = "txt";
                }
            }
 
            IconInf oIconInf2 = icons[sExtn];           
            return oIconInf2;
 
        }
       
    }
}

Friday, September 19, 2008

StringTableModel1Col JAVA jtable table model for one column of data all of type string

/**
*

StringTableModel1Col JAVA jtable table model for one column of data all of type string

@author tushar.kapila at gmail .com

*/
package xmltagger.common;
 
import javax.swing.table.*;
import java.util.*; import javax.swing.*;
 

public class StringTableModel1Col extends AbstractTableModel{
 ArrayList<String> data = new ArrayList<String>();// need array of arrays for multi col
 
 public void setValueAt(Object aValue,
                       int rowIndex,
                       int columnIndex){
 
  if(rowIndex >= data.size()){
   int toAdd = rowIndex - data.size();
   for(int i = 0; i < toAdd; i++){
    data.add("");
   }
  }
  data.set(rowIndex,(String)aValue);
 }
 
  public int getRowCount(){
   return data.size();
  }
  public int getColumnCount(){
   return 1;
  }
  public Object getValueAt(int row, int column){
   return data.get(row);
  }
 
}

Wednesday, September 17, 2008

mocha host - bad www.MochaHost.com

I used mocha host for jsp / java servlets hosting - but they are bad - could not get jsps to work and they did not refund even though I asked for a cancel when I could not get it to work :

 Posted On: 05 Sep 2008 12:49 AM
i requested the restart 2 days back but i got no email informing me of restart ! nor does it seem to have worked the site is not working - jsp not appearing.
 
eatj gives better free service please cancel this account and refund as i asked for java but never got it
 

Sunday, September 7, 2008

IE DEFAULT PRINT

HEADER
 
&w&bPage &p of &P
 
FOOTER
&u&b&d
 

Saturday, August 30, 2008

html javascript A demo showing html UI reacting in real time

A demo showing html UI reacting in real time.

Number 1
Number 2
Operation
Result
.
The html:
<html>
<title>A demo showing html UI reacting in real time.</title>
<body>
<form name=f1 action=aa type=get>
<table >
<tr><td>
Number 1</td> <td><input id=t1 onChange=t1c()></td>
 
</tr>
 

<tr><td>
Number 2</td> <td><input id=t2 onChange=t1c()></td>
 
</tr>
 

<tr id=oprw><td>
Operation</td> <td><select id=op onChange=t1c()>
<option value=a>+<option>
<option value=s>-<option>
<option value=m>*<option>
<option value=d>/<option>
</select></td>
 
</tr>
 
<tr><td>
Result</td> <td><input id=r disabled=true></td>
 
</tr>
<tr>
 
<td><input id=d1 onChange=d1c()></td>
</table>
</form>.
<script>
 
function t1c(){
 //alert("t1c");
 var op = document.getElementById("op");
 var t1 = document.getElementById("t1");
 var t2 = document.getElementById("t2");
 var oprw = document.getElementById("oprw");
 if(isNaN(t2.value))return;
 var r =  document.getElementById("r");
 alert("t1c " + t1.value + " t2 " + t2.value + " op " + op.value
 + " Number( t1.value) "+ Number( t1.value)
 + " Number( t2.value) "+ Number( t2.value));
 r.disabled = false;
 switch (op.value){
  case 'a':
  alert ("add" + (Number( t1.value) + Number( t2.value)))
   //r.value = Math.parseDouble(t1.value) + Math.parseDouble(t2.value);
   r.value = String (Number( t1.value) + Number( t2.value));
   break;
  case 's':
   //r.value = Math.parseDouble(t1.value) + Math.parseDouble(t2.value);
   r.value = (1 * t1.value) - (1 * t2.value);
   break;
  case 'm':
   //r.value = Math.parseDouble(t1.value) + Math.parseDouble(t2.value);
   r.value = (1 * t1.value) * (1 * t2.value);
   break;
 
  case 'd':
   //r.value = Math.parseDouble(t1.value) + Math.parseDouble(t2.value);
   r.value = (1 * t1.value) / (1 * t2.value);
   break;
 
 }
 r.disabled = true ;
}
</script>
 
 
</body>
</html>
 
Same but not escaped:
Number 1
Number 2
Operation
Result
. ;

Regards
Tushar Kapila
http://sel2in.com
Java, PHP, VB6 Apps. Fight Back pain: Exercise timer application
http://ksoft7.tripod.com/g3.html search page that allows you to search within any website uses google works best in Internet explorer and opera
http://minutes-alarm.sourceforge.net freeware minute alarm, easy reminder for back ache - stand up or meeting ...


Volunteer computer Cancer cures www.worldcommunitygrid.org
Click: www.thehungersite.com , and www.bhookh.com feed hungry , its free. www.ecologyfund.com
Physics-particle research & you helping http://stephenbrooks.org/muon1
Please add these to your start-up how to: http://tusharkapila.blogspot.com/2008/05/s.html

Saturday, August 16, 2008

Java Drop Shadow text effect download source

http://java.sun.com/developer/Books/2dgraphics/index.html good 3 d graphics attached new code for java 6 get the code from http://sel2in.com/pages/prog/java/awt/dropShadowText/download_java_2d_api_shadow_drop_text.html attachments not allowed here :(

Friday, June 13, 2008

Testing Web Applications With a Real URL on local system on Windows

moved to http://how2that.blogspot.com/2009/12/testing-web-applications-with-real-url.html

Sunday, May 11, 2008

html javascript: change page title

To change the title of a document can use
 
<script type="text/javascript">
document.title = document.title  + " :Run Mailer"; </script>
 
Useful when the title comes from a template but you want to customize
 
Ofcouse you dont have to append old title can just be
 
<script type="text/javascript">
document.title = "Run Mailer";
</script>

Regards
Tushar Kapila
http://sel2in.com
Java, PHP, VB6 Apps. Fight Back pain: Exercise timer application
http://ksoft7.tripod.com/g3.html search page that allows you to search within any website uses google works best in Internet explorer and opera
http://minutes-alarm.sourceforge.net freeware minute alarm, easy reminder for back ache - stand up or meeting ...

Volunteer computer Cancer cures www.worldcommunitygrid.org
Click: www.thehungersite.com , and www.bhookh.com feed hungry , its free. www.ecologyfund.com
Please add these to your start-up how to: http://tusharkapila.blogspot.com/2008/05/s.html
 

Regards
Tushar Kapila
http://sel2in.com
Java, PHP, VB6 Apps. Fight Back pain: Exercise timer application
http://ksoft7.tripod.com/g3.html search page that allows you to search within any website uses google works best in Internet explorer and opera
http://minutes-alarm.sourceforge.net freeware minute alarm, easy reminder for back ache - stand up or meeting ...

Volunteer computer Cancer cures www.worldcommunitygrid.org
Click: www.thehungersite.com , and www.bhookh.com feed hungry , its free. www.ecologyfund.com
Please add these to your start-up how to: http://tusharkapila.blogspot.com/2008/05/s.html


G
 
Forum
Ads by google:











Source code, testing article - one stop shop Software applications written in Java for cell phones, PHP, Java Dot net, PHP & Perl for the web and Vb6, Java, VB6, Perl and Excel VBA for the desktop .

- Tushar G Kapila
Bangalore India 2007 © Remaining page can be removed if you save on your pc or server.

Contributors