Ads Inside Post

Search in This Blog

android.os.NetworkOnMainThreadException


android.os.NetworkOnMainThreadException


if you work with android and want to get data from any url by using URL and  URLConnection you me stuck by the "android.os.NetworkOnMainThreadException" error message while run the app.

To over come this run time error message you use "StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();  StrictMode.setThreadPolicy(policy);" as listed below.

Keep in mind that use it in onCreate(Bundle savedInstanceState) after "setContentView(R.layout.activity_main);" method

//////////////////////////////////////////
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
//// other code here
}
//////////////////////////////////////////

Multiple Find Replace in MS Word using C#

Multiple Find Replace in MS Word using C#

Suppose you have a Ms word file with 100s or more pages and each page have a word more than 10 or multiple times which you want to replace. In this situation you will open the doc file and open find replace box. but this is time taking task.

replace words in msword










I have developed the .Net framework 4.5 windows application. by using this application you choose the file and put the find and replace word and press "Replace Now!" button.

To run this application you need to install .Net framework 4.5 from Microsoft site

Download here
https://sourceforge.net/projects/unique-softwares/files/in-ms-word-using-c.html







use Table in itextsharp C#

use Table in itextsharp C#





iTextSharp.text.Document doc = new iTextSharp.text.Document(PageSize.A4, 6, 72, 20, 16);
doc.Open();
PdfWriter docWriter = PdfWriter.GetInstance(doc, new FileStream(PdfName, FileMode.Create));
docWriter.StrictImageSequence = true;

PdfPTable table = new PdfPTable(1);
table.TotalWidth = 550f;
table.LockedWidth = true;

for(n records) {
    PdfPCell cell = new PdfPCell(new Phrase(""));
        cell.AddElement(pdfImage);
        cell.BorderColor = BaseColor.WHITE;
        table.AddCell(cell);
}
doc.Add(table);
doc.Close();

Thin border table in html

How to create Thin border table in html:
Use following html code to create Thin border table in html.


<table cellspacing="0" cellpadding="1" style="border-color:Black;border-width:1px;border-style:Solid;height:108px;width:100%;border-collapse:collapse;" rules="all" >
  <tbody>
    <tr >
      <th scope="col">Date</th>
      <th scope="col">Time</th>
      <th scope="col">Status at</th>
      <th scope="col">Status</th>
    </tr>
    <tr>
      <td align="center">25/08/2014</td>
      <td align="center">10:20:15</td>
      <td align="left">Status A</td>
      <td align="left">Status B</td>
    </tr>
  </tbody>
</table>

Get cookies in java

How to get cookies in java


import java.io.*;
import java.net.*;
public class CO {
    public static void main(String ss[]) {
     try {
             String url="http://www.mywebsite.com/anything.do";
              HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
        System.out.println("\n[HTTP GET RESPONSE]");
        System.out.println("==== Response Headers =====");
        String serverCookies = conn.getHeaderField("Set-Cookie");
        if(serverCookies != null) {
                    String[] cookies = serverCookies.split(";");
                    for(String s : cookies){
                        s = s.trim();
                        if(s.split("=")[0].equals("JSESSIONID")){
                                String J_SESSION_ID = s.split("=")[1];
                                System.out.println(" Session ID Found: " + J_SESSION_ID);
                            }
            }
        }
    } catch(Exception ee) {
        System.out.println(ee.toString());
    }
    }
}

Image Optimizer

Jpg Image Optimizer



Optimize your images,just select source and target folder and click on "Start Optimize"


Jpg Image Optimizer















Download it here

How to use Limit in ms access sql query

How to use Limit in ms access sql query


use below ms access sql
SELECT TOP 90 PERCENT * FROM tablename

Load image in picturebox in C#

Load image in picturebox in C#

How to load image in picturebox in dot net C# winform, Listed below code will solve your problem.


pictureBox1.Image = System.Drawing.Image.FromFile("ImageNameWithFullPath");

Get height width of image in C#

Get height width of image in C#


You can simply get image's height width in C# with only one line of code:
the code is :

int h = System.Drawing.Image.FromFile("ImageNameWithPath").Height;
int w = System.Drawing.Image.FromFile("ImageNameWithPath").Width;

SQL query for two column from and to with same value

SQL query for two column from and to with same value

Suppose you are developing a software, you have a database table with following structure:
zip_id from_zip1 from_zip2 ship_cost
1         0         100         40
2         101         200         50
3         201         350         100

In the data entry screen you put the Zip code as 315. Zip code 315 coming under zip id 3 and it's shipping cost is 100.
you want when user put zip 315 or any other zip then it's according shop cost automatically show.
So what will the sql query of this?

This will the query of that:

SELECT *FROM ship
WHERE (from_zip2>=315 AND from_zip1<=315)
ORDER BY from_zip2 DESC LIMIT 0, 1


Auto Resume Broken File Uploader

Auto Resume Broken File Uploader With Progress Bar


Internet connection broken is the very common problem with of all us. When clients are upload large (GBs size) file via web page, they need uninterrupted internet connection supply. If internet connection breaks, then need to re-upload file. and if internet connection breaks many times during uploading, then clients need to upload the file many times again and again and so on.

So I have invented this "Auto Resume Broken & Progress Bar File Uploader" without using any third party or DLL file.

By this uploader upload Unlimited GBs file without fear of internet connection break. Also I have added another Fast/Slow send Bytes speed, whatever depends on your internet connection. Suppose you have slow connection, you can set slow send bytes on the other hand if you are having fast connection set fast send bytes.

Auto Resume Broken File Uploader




User not need to stay on computer screen and do other work. I have created these uploader in many technologies(JSP/SERVLET, PHP, ASP.NET) and many flavors.

Probably I’m not allowed to post the source code in public, so I’m just going to show you it's screenshot that how can achieve it from webpage.






MS Access alphanumeric column sorting as number

Alphanumric column sorting as numeric in MS Access

You have Ms Access Database table as listed belwo:
------------------------------------------
id,p_num, city,branch
------------------------------------------ 
1,P1,a,b
2,P9,c,d
3,P19,e,f
4,P2,g,h
5,P111,i,j
6,P100,k.l
7,P10,m,n
8,P7,o,p
------------------------------------------

Now you want to show the record by "p_num" column, you can see "p_num" is a alphanumeric value and you want to sort is as below:
------------------------------------------ 
id,p_num, city,branch
------------------------------------------ 
1,P1,a,b
2,P2,g,h
3,P7,o,p
4,P9,c,d
5,P10,m,n
6,P19,e,f
7,P100,k.l
8,P111,i,j
------------------------------------------
So in this case use this sql:

SELECT id,Mid(p_num,2,12) AS new_p_num,city,branch FROM my_tbl order by CInt(Mid(p_num,2,12) )

In the above sql query "Mid(p_num,2,12)" 2 is the starting position of p_num column and 12 is the maximum digits. Here I am assuming after "P" number is not more that 12 digits.


PDF file merge



 PDF file merge


If you have more than one PDF files with multiple pages and you need to merge all the files into a single pdf  file. Then you can move on internet and search for that. There are many more websites that are providing the free facility to combine multiple PDF files and generate one single file. 
But due to security issues we can not upload important pdf files to any website that are proving this type  of facilities.
 






I have created this .Net Windows application that will take multiple pdf files and combine them into one single pdf file. The more important thing is that I have made it with batch processing. So just select the directory which having the pdf files.

Download

Video Watermark

Video Watermark


Add Subtitle ( Watermark in video ) in your video by this software.
Currently this support .AVI, .FLV and .MOV format.
I have created it in "Dot Net Framework 4 Client Profile", So  needed to download  .Net Framework 4 Client Profile from Microsoft site.

Watermark in video


In my next version I will add some more video format.

Download








Text to speech in dot net

Text to speech in dot net


Enjoy text to speech,just download this application.
To run this application you need to install Dotnet framework 3.5











Download here:
http://agalaxycode.blogspot.com/2015/03/text-to-speech.html














Secure File Delete

Secure File Delete


Privacy is very important in our real life and information technology. If you have a very important file and after some time you want to no one can see this file content, So what you will do in this case? You will say simple answer, “I will delete that file from my computer system”. Okay you can delete that file, but did you think anyone can restore your file using “Recovery Software”.  So now what you will do now?

Secure File Delete
Ok, no problem, I have created a Software that will delete any file from your computer system and no one can recover it using any recovery software.

Download it and Enjoy!!!!

Resize grid automatically when resize windows in wpf


Resize grid automatically when resize windows in wpf



----------------------------------------------------------------------------------------------
In <Grid Height="357.714" Width="504.798" Background="Chocolate">
remove the Height="357.714" Width="504.798",that will solve your problem.

Spilt in C# with word and character

Spilt in C# with word and character



// Split using single character 
String nms1="aa,bb,cc,dd,ee";
string[] nm1 = nms1.Split(',');


// Split using word 
using System.Text.RegularExpressions;

String nms2="aa<name>bb<name>cc<name>dd<name>ee";
string[] nm2 = Regex.Split(nms2, "<name>");

Dictionary in C#

Dictionary in C#

Dictionary is faster that ArrayList and HashTable in C#, here is the example that how to use Dictionary in C#.



Dictionary<int, string> dict = new Dictionary<int, string>();
//You are free to use either :
//Dictionary<string,int> dict = new Dictionary<string,int>();
dict.Add(1, "AA");
dict.Add(2, "BB");
dict.Add(3, "CC");

foreach (var data in dict) {
      nmCode = data.Key.ToString();
      nm = data.Value.ToString();
}



Parse single line JSON data in C#

Parse Single line JSON data in C# without objects

If you have received this JSON data string as listed below:
[‘aa’,’bb’,’cc’ ,’dd’,’ee’ ,’ff’,’gg’ ,’hh’,’ii’ ,’jj’,’kk’ ,’ll’,’mm’ ,’nn’,’oo’]

This is the array of JSON, you can see there are no Object data in that JSON string.
So, how you retrieve this JSON data in C#?
I have used JSON.Net from Newtonsoft.Json. it is a free library so you can download it from their site.






using Newtonsoft.Json.Linq;

String jsonData=”[‘aa’,’bb’,’cc’ ,’dd’,’ee’ ,’ff’,’gg’ ,’hh’,’ii’ ,’jj’,’kk’ ,’ll’,’mm’ ,’nn’,’oo’]”;
JArray names= JArray.Parse(jsonData);
//By foreach loop
foreach (Object nm in names){
    MessageBox.show(nm.toString());
}
// By For loop
for (int j=0; i< names.Count;j++) {
String nm = names [j].ToString();
MessageBox.show(nm.toString());
}