Welcome to CodeGlobe. CodeGlobe provides free source code, tutorials and latest useful technology news.
Thursday, February 25, 2010
wkhtmltopdf
http://code.google.com/p/wkhtmltopdf/
Guide
Try this commad
wkhtmltopdf www.myhomepage.com myhomepage.pdf
for a list of available options see
wkhtmltopdf --help
Features
* Convert web pages into PDF documents using webkit
* Adding headers and footers (static version only)
* TOC generation (static version only)
* Batch mode conversions
* (Linux) No longer requires an XServer to be running (however the X11 client libs must be installed)
Saturday, February 20, 2010
Way2SMS send sms C# Code
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
namespace SMSAPI
{
class SmsSender
{
void send(string uid, string pwd, string no, string msg)
{
String content = "username="+uid+"&password="+pwd;
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://wwwa.way2sms.com/auth.cl");
request.KeepAlive = false;
byte[] byteArray = Encoding.UTF8.GetBytes(content);
CookieContainer cookies = new CookieContainer();
request.CookieContainer = cookies;
request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5";
request.ContentLength = byteArray.Length;
request.ContentType = "application/x-www-form-urlencoded";
request.Accept = "*/*";
request.Referer = "http://wwwg.way2sms.com//entry.jsp";
request.Method = "POST";
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
foreach (Cookie cook in response.Cookies)
{
cookies.Add(cook);
}
Stream stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream);
string serverData = reader.ReadToEnd();
reader.Close();
content = "custid=undefined&HiddenAction=instantsms&Action=custfrom450000&login=&pass=&MobNo="+no+"&textArea="+msg;
request = (HttpWebRequest)WebRequest.Create("http://wwwa.way2sms.com/FirstServletsms?custid=");
byteArray = Encoding.UTF8.GetBytes(content);
request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5";
request.ContentLength = byteArray.Length;
request.ContentType = "application/x-www-form-urlencoded";
request.Accept = "*/*";
request.CookieContainer = cookies;
request.Method = "POST";
dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
response = (HttpWebResponse)request.GetResponse();
stream = response.GetResponseStream();
reader = new StreamReader(stream);
serverData = reader.ReadToEnd();
reader.Close();
request = (HttpWebRequest)WebRequest.Create("http://wwwa.way2sms.com/jsp/logout.jsp");
byteArray = Encoding.UTF8.GetBytes(content);
request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5";
request.ContentLength = byteArray.Length;
request.ContentType = "application/x-www-form-urlencoded";
request.Accept = "*/*";
request.CookieContainer = cookies;
request.Method = "POST";
dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
response = (HttpWebResponse)request.GetResponse();
stream = response.GetResponseStream();
reader = new StreamReader(stream);
serverData = reader.ReadToEnd();
reader.Close();
}
catch (ArgumentException e)
{
Console.WriteLine("arg exception");
Console.Read();
}
catch (WebException e)
{
Console.WriteLine("web exception");
Console.Read();
}
catch (Exception e)
{
Console.WriteLine("exception");
Console.Read();
}
}
static void Main(string[] args)
{
SmsSender sms = new SmsSender();
sms.send("username", "password", "phno_recipient", "message");
}
}
}
cochin IT solutions -web hosting web development cellphone applications business solutions seo services
Way2SMS Source Exposed
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Iterator;
import java.util.Vector;
public class SMS {
public static void send(String uid, String pwd, String phone, String msg)
throws IOException {
if ((uid == null) || (uid.length() == 0)) {
throw new IllegalArgumentException("User ID should be present.");
}
uid = URLEncoder.encode(uid, "UTF-8");
if ((pwd == null) || (pwd.length() == 0)) {
throw new IllegalArgumentException("Password should be present.");
}
pwd = URLEncoder.encode(pwd, "UTF-8");
if ((phone == null) || (phone.length() == 0)) {
throw new IllegalArgumentException(
"At least one phone number should be present.");
}
if ((msg == null) || (msg.length() == 0)) {
throw new IllegalArgumentException("SMS message should be present.");
}
msg = URLEncoder.encode(msg, "UTF-8");
Vector numbers = new Vector();
if (phone.indexOf(59) >= 0) {
String[] pharr = phone.split(";");
for (String t : pharr)
try {
numbers.add(Long.valueOf(t));
} catch (NumberFormatException ex) {
throw new IllegalArgumentException(
"Give proper phone numbers.");
}
} else {
try {
numbers.add(Long.valueOf(phone));
} catch (NumberFormatException ex) {
throw new IllegalArgumentException("Give proper phone numbers.");
}
}
if (numbers.size() == 0) {
throw new IllegalArgumentException(
"At least one proper phone number should be present to send SMS.");
}
String temp = "";
String content = "username=" + uid + "&password=" + pwd;
URL u = new URL("http://wwwa.way2sms.com/auth.cl");
HttpURLConnection uc = (HttpURLConnection) u.openConnection();
uc.setDoOutput(true);
uc
.setRequestProperty(
"User-Agent",
"Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5");
uc.setRequestProperty("Content-Length", String
.valueOf(content.length()));
uc.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
uc.setRequestProperty("Accept", "*/*");
uc.setRequestProperty("Referer", "http://wwwg.way2sms.com//entry.jsp");
uc.setRequestMethod("POST");
uc.setInstanceFollowRedirects(false);
PrintWriter pw = new PrintWriter(new OutputStreamWriter(uc
.getOutputStream()), true);
pw.print(content);
pw.flush();
pw.close();
BufferedReader br = new BufferedReader(new InputStreamReader(uc
.getInputStream()));
while ((temp = br.readLine()) != null) {
System.out.println(temp);
}
String cookie = uc.getHeaderField("Set-Cookie");
u = null;
uc = null;
for (Iterator localIterator = numbers.iterator(); localIterator
.hasNext();) {
long num = ((Long) localIterator.next()).longValue();
content = "custid=undefined&HiddenAction=instantsms&Action=custfrom450000&login=&pass=&MobNo="
+ num
+ "&textArea="
+ msg;
u = new URL("http://wwwa.way2sms.com/FirstServletsms?custid=");
uc = (HttpURLConnection) u.openConnection();
uc.setDoOutput(true);
uc
.setRequestProperty(
"User-Agent",
"Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5");
uc.setRequestProperty("Content-Length", String.valueOf(content
.getBytes().length));
uc.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
uc.setRequestProperty("Accept", "*/*");
uc.setRequestProperty("Cookie", cookie);
uc.setRequestMethod("POST");
uc.setInstanceFollowRedirects(false);
pw = new PrintWriter(new OutputStreamWriter(uc.getOutputStream()),
true);
pw.print(content);
pw.flush();
pw.close();
br = new BufferedReader(new InputStreamReader(uc.getInputStream()));
while ((temp = br.readLine()) != null)
;
br.close();
u = null;
uc = null;
}
u = new URL("http://wwwa.way2sms.com/jsp/logout.jsp");
uc = (HttpURLConnection) u.openConnection();
uc
.setRequestProperty(
"User-Agent",
"Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5");
uc.setRequestProperty("Accept", "*/*");
uc.setRequestProperty("Cookie", cookie);
uc.setRequestMethod("GET");
uc.setInstanceFollowRedirects(false);
br = new BufferedReader(new InputStreamReader(uc.getInputStream()));
while ((temp = br.readLine()) != null)
;
br.close();
u = null;
uc = null;
}
}
best web hosting plan providers-cochin/kerala
cellphone application developers Kerala/India
Tuesday, February 9, 2010
Another adding to Google Doc
Uploading and exporting: Uploading any file
You can upload one or multiple files to Google Docs. Here's how:- Click the Upload button on the Docs list homepage.
- Click Select files to upload files from your computer. When the Browse dialog is open, select the file you'd like to upload to Google Docs. To select multiple files, press Shift or Ctrl and click all the files to upload. If you first select one file and then decide to upload more, click the Select more files link that appears after you upload the first file.
- Pick a folder to which you'd like to upload the files (this is optional), and click the Start upload button.
You can simply store the uploaded file in Google Docs, or convert it to Google Docs format so you can later edit it online. To store the file without converting it, make sure you deselect the option to convert the file. If you'd like to convert your document, presentation or spreadsheet to Google Docs format, you don't need to take any extra steps. The checkbox right below the Folder drop-down menu is selected by default.
File types and storage
You can upload any file type to be stored in Google Docs, but you can convert only certain types of files to Google Docs format.
Uploading and converting
When uploading a file to be converted to Google Docs, please keep the following in mind:
- You can only upload and convert these file types:
- For spreadsheets: .xls, .xlsx, .ods, .csv, .tsv, .txt, .tsb
- For documents: .doc, .docx, .html, plain text (.txt), .rtf
- For presentations: .ppt, .pps
- There are some file-size limits. See the size requirements for uploading and converting.
- Some of your original formatting may not be preserved.
Uploading and storing
Files that you store but don't convert can't be larger than 1 GB each. You get 1 GB of free storage for your Google Account, and you can purchase additional storage for $0.25 per GB.
Only stored files count towards the maximum limit. If you delete a file and empty trash, you get your storage back.
Finding your stored files
After you upload a file which hasn't been converted to Google Docs format, you'll see it in all your regular views. You can also find it under Items by type > Files.
When you open one of these stored files on your Docs list, you can choose to see a preview of the file, share the file, print it, or download it to your desktop. You can also edit it on locally on your computer (for example, upload a photo, make changes using a photo editor) and then upload the new version of the file to Google Docs.
Important notes:
- You can share a stored file that hasn't been converted, but can't actually collaborate with someone on it because the file is incompatible with Google Docs format.
- Your storage quota includes plenty of bandwidth for ordinary use. If there's excessive bandwidth use, we may limit your access for a period of time.
Uploading files with the Google Docs List Data API
If you're a premier Apps customer, you can also upload multiple files to Google Docs by using the Google Docs List Data API. It allows client applications to upload documents to Google Docs and list them in the form of Google Data API ("GData") feeds. Learn more about the Google Documents List Data API.