Thursday, May 8, 2014

Send Email/Message from Mobile to Email ID through SMS


Use TxtWeb Service provider, follow this link http://www.txtweb.com/apps/email

Supports
Mobile:  Idea, Airtel, Tata Docom
Email Account: Gmail & Yahoo.accounts

How to use this Service:
1) Register the your Mobile No and Email ID  to TxtWeb via SMS
@email register <your email id> to 51115  (Recommended)
       or
@email to 51115

Note: your - who are sending email to others; SMS Charge - Upto Rs 1/SMS

2) After getting the welcome message from TxtWeb, Now you can send email to anybody via SMS
@email <recipient email id> -s <subject> -b <body> to 51115


Note: It sends a mail on your behalf to the recipient. The sender address is owned by TxtWeb i.e the sender address would be txtweb.mailer@gmail.com. 
If you register your email id to TxtWeb then your mail id shown to recipient in body section of mail like Mail sent by <register mail id> at the end of mail.

Saturday, March 15, 2014

Reserved words in Access

Extract Last Name from Name Field in Access



Follow the below expression for extracting last name

1) if Name field combination of First name and Last name only (no middle name) like Shashi Singh then
  extracting expression is Right(Trim([Names]),Len(Trim([Names]))-InStr(1, [Names]," "))

  Note: Instr() will find a specific string within a string, and will return the starting position. So in this case, you                want to find where that space is, and then return everything to the right of it. [string first character position            count as a 1 in Instr()]. For more details about Instr() visit 
                  http://office.microsoft.com/en-in/access-help/instr-function-HA001228857.aspx


2) if Name field combination of First name, Middle name and Last name only like Shashi Shankar Singh then
  extracting expression is
        Right(Trim([Names]),Len(Trim([Names]))-InStr(InStr(1, [Names]," ")+1,[Names]," "))

3) if Name field may have middle name or not eg: Shashi Singh or Shashi Shankar Singh then extracting expression is  IIf(InStr(InStr([names]," ")+1,[names]," ")<>0, Right([names],Len([names])-InStr(InStr([names]," ")+1, [names]," ")),Right([names],Len([names])-InStr([names]," ")))
 

Use in Update Query:
update <Table_name> set Caste=IIf(InStr(InStr(Trim([Relation_Name])," ")+1,Trim([Relation_Name])," ")<>0, ight(Trim([Relation_Name]),Len(Trim([Relation_Name]))- InStr(InStr(Trim([Relation_Name])," ")+1, Trim([Relation_Name])," ")), Right(Trim([Relation_Name]), Len(Trim([Relation_Name]))-InStr(Trim([Relation_Name])," ")))




Extracting First Name then expression is Left([Names],InStr(1,[Names]," ")-1)

Note: Since you do not want to include the space itself, we subtact 1 (one) from the result of the Instr function. Note this will return an #Error if it doesn't find a space, since Instr() returns 0 if string not found, and you cant take the Left Negative 1 characters. So this will work if EVERY record has a space in it.

Solution is LEFT([NameField], INSTR(1,[NameField] & " "," ")-1)

It will work for nulls, zero-length strings, and fields that don't contain a space, The trick is ensuring that the Instr can always find a space by adding a space to the end of the string.


Copied from http://support.microsoft.com/kb/286238 , http://www.pcreview.co.uk/forums/query-trim-name-field-t3978454.html

Sunday, February 16, 2014

How to copy values/items from dropdown in web page

visit this page http://techbrij.com/copy-extract-html-drop-down-list-options-text

1. Open site.
2. Now you need to get HTML source of dropdown list:
For Firefox with Firebug: 
Right Click on HTML Dropdownlist, Select Inspect Element and In firebug, Right click and clickcopy InnerHTML option.
For IE8+:
Press F12, click arrow sign in developer tools and Select Dropdownlist. Now you will see html source is selected in developer tools, right click and click copy InnerHTML option.
For Chrome:
Right Click on HTML Dropdownlist, Select Inspect Element and In Developer Tools, you will see html source is selected. Right click and click Copy as HTML option.
3. Paste HTML source in Notepad++
4. Remove Select tag from top and bottom if exists
5. Put cursor at top of code and Press Ctrl + F
6. Go to Replace Tab and enter following info:
Find What:
<option[^>]*>([^<]*)</option>
Replace With:
\1\n
Select Regular Expression as Search Mode and click on Replace All. If options are already in new line then no need to use \n in Replace With option.


To get rid of leading space(s) and all empty lines (even if the empty line contains spaces or tabs)
  1. Go to Search -> Replace
  2. Select "Regular expression" under Search mode.
  3. Use ^\s* for "Find what" and leave "Replace with" blank.
  4. Click Replace all
Regex explanation:
  • ^ means beginning of the line
  • \s* means any number (even 0) of whitespace characters. Whitespace characters include tab, space, newline, and carriage return.

How to extract a URL from a hyperlink on Excel

visit this site: http://howtouseexcel.net/how-to-extract-a-url-from-a-hyperlink-on-excel



  1. Open up a new workbook.
  2. Get into VBA (Press Alt+F11)
  3. Insert a new module (Insert > Module)
  4. Copy and Paste the Excel user defined function below
  5. Get out of VBA (Press Alt+Q)
  6. Use this syntax for this custom Excel function: =GetURL(cell,[default_value])
Function GetURL(cell As range, _
Optional default_value As Variant)
'Lists the Hyperlink Address for a Given Cell
'If cell does not contain a hyperlink, return default_value
If (cell.range("A1").Hyperlinks.Count <> 1) Then
GetURL = default_value
Else
GetURL = cell.range("A1").Hyperlinks(1).Address & "#" & cell.range("A1").Hyperlinks(1).SubAddress
End If
End Function

Tuesday, January 28, 2014

How to Change Pixel Color of Image in C#


Copied from the Site: http://stackoverflow.com/questions/17208254/how-to-change-pixel-color-of-an-image-in-c-net

var originalColor = scrBitmap.GetPixel(i, j);
if (originalColor.R == 0 && originalColor.G == 0 && originalColor.B == 0)
    newBitmap.SetPixel(i, j, Color.FromArgb(originalColor.A, Color.Red));
Now you'll see that it works but it takes a very long time to process each image: GetPixel andSetPixel are pretty slow (primary because they check and calculate everything for each call). It's much better to handle bitmap data directly. If you know the image format in advance (32 bit-per-pixel to 8 bit-per-pixel) then you can do it much much faster with LockBits:
The Bitmap class provides the LockBits and corresponding UnlockBits methods which enable you to fix a portion of the bitmap pixel data array in memory, access it directly and finally replace the bits in the bitmap with the modified data. LockBits returns a BitmapData class that describes the layout and position of the data in the locked array.
static unsafe Bitmap ReplaceColor(Bitmap source,
                                  Color toReplace,
                                  Color replacement)
{
  const int pixelSize = 4; // 32 bits per pixel

  Bitmap target = new Bitmap(
    source.Width,
    source.Height,
    PixelFormat.Format32bppArgb);

  BitmapData sourceData = null, targetData = null;

  try
  {
    sourceData = source.LockBits(
      new Rectangle(0, 0, source.Width, source.Height),
      ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);

    targetData = target.LockBits(
      new Rectangle(0, 0, target.Width, target.Height),
      ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);

    for (int y = 0; y < source.Height; ++y)
    {
      byte* sourceRow = (byte*)sourceData.Scan0 + (y * sourceData.Stride);
      byte* targetRow = (byte*)targetData.Scan0 + (y * targetData.Stride);

      for (int x = 0; x < source.Width; ++x)
      {
        byte b = sourceRow[x * pixelSize + 0];
        byte g = sourceRow[x * pixelSize + 1];
        byte r = sourceRow[x * pixelSize + 2];
        byte a = sourceRow[x * pixelSize + 3];

        if (toReplace.R == r && toReplace.G == g && toReplace.B == b)
        {
          r = replacement.R;
          g = replacement.G;
          b = replacement.B;
        }

        targetRow[x * pixelSize + 0] = b;
        targetRow[x * pixelSize + 1] = g;
        targetRow[x * pixelSize + 2] = r;
        targetRow[x * pixelSize + 3] = a;
      }
    }
  }
  finally
  {
    if (sourceData != null)
      source.UnlockBits(sourceData);

    if (targetData != null)
      target.UnlockBits(targetData);
  }

  return target;
}

Note: To run the unsafe code in C#, you have to do: Open the properties for the project, go to the Build tab and check the Allow unsafe codecheckbox.