Multiple image format change using photoshop


This tutorial will go over how to Change format of multiple images at  once using Photoshop. This is also known as Bulk image format change in Photoshop(bridge).

If you want to convert image from one format to another, Photoshop and Photoshop Tools allow you to do this in just few minutes. For doing this process you requires Photoshop File Browser (or Adobe Bridge in CS3 or higher).

1) Open Photoshop.

2) click on "FILE" menu.


 3) Select "Browse in Bridge" option.
    A new window will open.
    In a "content" window select images you want to rename.

4) click on "Tool" Menu   


5) Hover "Photoshop" Menu.
    select "Image Processor" option.
    A new window will open
 
6) Select various options as per requirement like
    Destination folder,
    Image type,
    Copyright info 

7) Click on "Run" Button.
   
    Its done :)

0 comments :

Rename multiple images ( Batch Rename Files in Photoshop )



This tutorial will go over how to Rename multiple images at  once using Photoshop. This is also known as Batch Rename Files in Photoshop.

If you want to rename a series of files -- such as several pictures from a digital camera. Photoshop and Photoshop Tools allow you to do this in just few minutes. For doing this process you requires Photoshop File Browser (or Adobe Bridge in CS3 or higher).

1) Open Photoshop.

2) click on "FILE" menu.


 3) Select "Browse in Bridge" option.
    A new window will open.
    In a "content" window select images you want to rename.

4) click on "Tool" Menu


5) select "Batch Rename" option
    A new window will open

6) Select various options like
    Destination folder,
    New File Names
        You can use Text, Sequence number, date and time for names of files
    You can see preview in preview box.


7) Click on "Rename" Button.
   
    Its done :)

0 comments :

Export Mysql data in MS Excel using php



This tutorial will go over how to download Mysql data into Excel file. This is Very useful for generating Excel Reports of Php Applications, and database. 


<?php
      //database credentials
      $username = "user_name";
      $password = "password";
      $host = "host_name";
      $dbname = "database_name";

      //Connect to database      $connector = mysql_connect($host,$username,$password)
          or die("Unable to connect");
        //echo "Connections are made successfully::";


     //Select database
      $selected = mysql_select_db($dbname, $connector)
        or die("Unable to connect");

      //execute the SQL query and return records
      $result = mysql_query("SELECT col1, col2, col3 FROM tablename");

    $contents="<table border='1'><tr><th>COL1</th><th>COL2</th><th>COL3</th></tr>";
    while($row = mysql_fetch_array($result))
    {
        $contents.="<tr><td>".$row['col1']."</td>";
        $contents.="<td>".$row['col2']."</td>";
        $contents.="<td>".$row['col3']."</td></tr>";
       
    }
   
    $contents.="</table>";

//header to make force download the file
$file="Report.xls";

header("Content-type: application/vnd.ms-excel");
//.date() functions add current date to file name
header("Content-Disposition: attachment; filename=Report".date('Y-m-d').".xls");
echo $contents;

mysql_close($connector);
?>

Note:- When you run this script Force download of Excel file starts.

0 comments :

Disable right click on web page using javascript



This tutorial will go over how to DisableRight Mouse Click using javascript

<!-- turn off right click -->

<script language=javascript>
var message="";
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")
</script>

Note:- This only stops people from right clicking on your page and there is no real way to stop people from viewing your html, if someone is determined to see your code they will.

2 comments :

Write Data to file in .Net ( VB and C# )



This tutorial will go over how to write data to a text file in VB.Net and C#.Net

.Net uses StreamWriter Class To write data to file. StreamWriter is designed for character output in a particular encoding, whereas classes derived from Stream are designed for byte input and output.

VB .Net

Dim objWriter As New System.IO.StreamWriter("d:\abc.txt", True)  
objWriter.WriteLine("Some Text here")
objWriter.Close()

C# .Net

using (System.IO.StreamWriter objWriter = new System.IO.StreamWriter(@"abc.txt", true))
{
       objWriter.WriteLine("Some Text here");
}
objWriter.Close(); 
 

0 comments :

Read Data from text file in .Net ( VB and C#)



This tutorial will go over how to read data from a text file in VB.Net and C#.Net

.Net uses StreamReader Class To read data. StreamReader is designed for character input in a particular encoding, whereas the Stream class is designed for byte input and output. Use StreamReader for reading lines of information from a standard text file.

VB .Net

Dim line As String = ""
Dim objReader As New System.IO.StreamReader("d:\abc.txt", True) 
Do line = objReader.ReadLine()
Console.WriteLine(line)
Loop Until line Is Nothing
objReader.Close()

C# .Net
using (StreamReader objReader = new StreamReader("abc.txt")) 
{
    string line;
    // Read and display lines from the file
    while ((line = objReader.ReadLine()) != null) 
    {
         Console.WriteLine(line);
    }
}

0 comments :

Load random images from folder in Php



This tutorial will go over how to pull any image from a specified folder, store path in an array and display random image on a page.

Step 1:-
//Specify path to search images from directory
$dir = 'images/';

Step 2:-
//scan directory content using scandir() function
$filesscandir($dir);

Step 3:-
//take random value from array
$random_index = array_rand($files);

Step 4:- 
finally display image
echo "<img src=" .$dir . $files[$random_index] . ">";


But when you display images some times it displays some hidden files. you can check contents of array by using print_r() command.
==> print_r($files);
it will show output as follows.
==> Array ( [0] => . [1] => .. [2] => HHRCK.png [3] => dsgsdg.jpg 

I don't have enough rep to explain about this dots. This tradition comes from the Unix world. I guess it is because it allows you to quickly see the permissions for the current and parent directories on each call of ls.

. refers to the current directory .. refers to the parent directory.


You will have to filter them out manually.

As of PHP 5.3 there is the FilesystemIterator which extends the DirectoryIterator and skips dot-files by default. 
here i used another array with the value [ '.' , '..']
and then find the difference between two arrays

So final code is as follows

<?php
$dir = 'images/';
$files =array_diff(scandir($dir), array('..', '.'));
$random_index = array_rand($files);
echo "<img src=" .$dir . $files[$random_index] . ">";
?>


whenever you refresh page random images will display.

0 comments :

C program to find prime numbers between given range


#include<stdio.h>
void main()
{
int i, prime, upper, lower, n;

printf("\n\n\t ENTER THE LOWER LIMIT => ");
scanf("%d", &lower);
printf("\n\n\t ENTER THE UPPER LIMIT => ");
scanf("%d", &upper);
printf("\n\n\t PRIME NUMBERS ARE");
for(n=lower+1; n<upper; n++)
{
prime = 1;
for(i=2; i<n; i++)
if(n%i == 0)
{
prime = 0;
break;
}
if(prime)
printf("\n\n\t\t\t%d", n);
}
}

Output :-

ENTER THE LOWER LIMIT => 0
ENTER THE UPPER LIMIT =>  10

PRIME NUMBERS ARE

1

2

3

5

7

2 comments :

code to check whether a no is Armstrong no or not



#include<stdio.h>
int main(){
    int num,r,sum=0,temp;

    printf("Enter a number: ");
    scanf("%d",&num);

    temp=num;
    while(num!=0){
         r=num%10;
         num=num/10;
         sum=sum+(r*r*r);
    }
    if(sum==temp)
         printf("%d  It is an Armstrong number",temp);
    else
         printf("%d It is not an Armstrong number",temp);
    return 0;
}

Output:-

Enter a number: 153
It is an Armstrong number

0 comments :

Finding duplicate element from 1-100 numbers JAVA



import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class FindDuplicateNumber {

public static void main(String args[]){
int a[]={1,2,3,4,5,6,7,8,9,5};

System.out.println("Using arrays =>"+usingArrayDup(a));
}

// Finding duplicates using double arrays
private static int usingArrayDup(int[] a) {
//Finding duplicate number using two arrays
for(int i=0;i<a.length;i++){
for(int j=i+1;j<a.length;j++){
if(a[i]==a[j])
return a[i];
}
}
return 0;
}//Double arrays
}

Output:-

Using arrays =>5

2 comments :

Find missing number from array 0-100



public class MissingNumberInArray {

public static void main(String args[]){

int a[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
int asum = 0,sum = 0;
for(int i=1;i<=a.length;i++)
sum=sum+i;
for(int i=0;i<a.length;i++)
asum=asum+a[i];
int missnum=sum-asum;
System.out.println("Missing Number"+missnum);
}
}

Output:-

Missing Number =>20

0 comments :

find out longest palindrome in a given string JAVA


public class LongestPalindrom {
    public static void main(String args[]) {
        String str = " hello . you uoy nitin nitin era woh..";
        char[] a = str.toCharArray();
        int low = Integer.MAX_VALUE;
        int upper = Integer.MIN_VALUE;
        for (int i = 0; i < str.length(); i++) {
            int start = i;
            int end = i;
            while (start >= 0 && end < str.length()) {
                if (a[start] == a[end]) {
                    if (end - start > upper - low) {
                        upper = end;
                        low = start;
                    }
                    end++;
                    start--;
                } else {
                    break;
                }

            }

        }
        for (int i = 0; i < str.length(); i++) {
            int start = i;
            int end = i + 1;
            while (start >= 0 && end < str.length()) {
                if (a[start] == a[end]) {
                    if (end - start > upper - low) {
                        upper = end;
                        low = start;
                    }
                    end++;
                    start--;
                } else {
                    break;
                }
            }

        }
        for (int i = low; i <= upper; i++) {
            System.out.print(a[i]);
        }
    }
}

Output:-

LongestPalindrom
nitin nitin

0 comments :

Find all permutations of String using Recursion


# include <stdio.h>
# include <string.h>

/* Function to swap values at two pointers */
void swap (char *x, char *y)
{
    char temp;
    temp = *x;
    *x = *y;
    *y = temp;
}
 
/* Function to print permutations of string */
void permute(char *a, int i, int n)
{
   int j;
   if (i == n)
     printf("%s\n", a);
   else
   {
        for (j = i; j <= n; j++)
       {
          swap((a+i), (a+j));
          permute(a, i+1, n);
          swap((a+i), (a+j)); //backtrack
       }
   }
}

int main()
{
   char a[] = "ABC";
   int l=strlen(a);
   printf("String length => %d",l);
   permute(a, 0, l-1);
   getchar();
   return 0;
}

Output:-

String length => 3
ABC
ACB
BAC
BCA
CBA
CAB

0 comments :

Find permutations using Recursion


#include <stdio.h>

void print(const int *v, const int size)
{
  if (v != 0)   {
     int i;
    for(i = 0; i < size; i++)     {
      printf("%d", v[i] );
    }
    printf("\n");
  }
} // print

void visit(int *Value, int N, int k)
{
  static level = -1;
  int i;
  level = level+1; Value[k] = level;

  if (level == N)
    print(Value, N);
  else
   
    for(i = 0; i < N; i++)
      if (Value[i] == 0)
        visit(Value, N, i);

  level = level-1; Value[k] = 0;
}

main()
{
  const int N = 4;
  int Value[N];
  int i;
  for (i = 0; i < N; i++)
  {
    Value[i] = 0;
  }
  visit(Value, N, 0);
}

Output:-

1234
1243
1324
1423
1342
1432
2134
2143
3124
4123
3142
4132
2314
2413
3214
4213
3412
4312
2341
2431
3241
4231
3421
4321

0 comments :

Remove any given character from a String

public class RemoveChar4mString {

    public static void main (String[] args)
    {
        System.out.println (removeChar4mString ("My blog name is Sourcecode-kk",  'o'));
    }

    public static String removeChar4mString (String str, char charToBeRemoved)
    {
        if (str == null)
            return "";

        StringBuilder strBuild = new StringBuilder ();

        for (int i = 0; i < str.length (); i++)
        {
            char ch = str.charAt (i);
            if (ch == charToBeRemoved)
                continue;
            strBuild.append (ch);
        }
        return strBuild.toString ();
    }
}

output:-

My blg name is Surcecde-kk

this code removes all "o" character from given string "My Blog name is Sourcecode-kk"


0 comments :

convert number to words in php



<?php

$one= array(
        0                   => ' ',
        1                   => 'one',
        2                   => 'two',
        3                   => 'three',
        4                   => 'four',
        5                   => 'five',
        6                   => 'six',
        7                   => 'seven',
        8                   => 'eight',
        9                   => 'nine',
        10                  => 'ten',
        11                  => 'eleven',
        12                  => 'twelve',
        13                  => 'thirteen',
        14                  => 'fourteen',
        15                  => 'fifteen',
        16                  => 'sixteen',
        17                  => 'seventeen',
        18                  => 'eighteen',
        19                  => 'nineteen'
        );
       
    $ten = array (
        0    =>    '',
        1    =>    '',
        2    =>    'twenty',
        3    =>    'thirty',
        4    =>    'fourty',
        5    =>    'fifty',
        6    =>    'sixty',
        7    =>    'seventy',
        8    =>    'eighty',
        9    =>    'ninety'
        );
   
function num2word($n)
{
    echo "Enter no between 1 to 999999999 \n";
    if($n<=0 && $n>999999999)
        echo "please enter valid no";
    else
 {
                  pw((($n/10000000)%100)," crore ");
                  pw((($n/100000)%100)," lakh ");
                  pw((($n/1000)%100)," thousand ");
                  pw((($n/100)%10)," hundred ");
                  pw(($n%100)," ");
 }   
}       

function pw($n,$ch)
{
 global $one;
 global $ten;

 echo ($n>19) ? ($ten[$n/10]." ".$one[$n%10]) : $one[$n];
 if($n) echo $ch;
 }

echo "\n". num2word(123456789);       
echo "\n". num2word(123477);
echo "\n". num2word(1000);
echo "\n". num2word(999);

?>       

Output :-

twelve crore thirty four lakhs fifty six thousand seven hundreds eighty nine

one lakhs twenty three thousand four hundreds seventy seven

one thousand

nine hundreds ninety nine

0 comments :

C Program for Factorial using Recursive Function


#include<stdio.h>
#include<conio.h>
long int factorial(int n);
void main()
{
int n;
clrscr();
printf("Enter the number:\n\n");
scanf("%d",&n);
printf("Factorial of %d is %ld",n,factorial(n));
getch();
}
long int factorial(int n)
{
if(n<=1)
{
return(01);
}
else
{
n=n*factorial(n-1);
return(n);
}
}

Output:- 

Enter the number
5
Factorial of 5 is 120

0 comments :

C Program for Base Conversion from Binary to Decimal


#include<stdio.h>
#include<conio.h>
int power (int);
void main()
{
long int n;
int x,s=0,i=0,flag=1;
clrscr();
printf("Input a Binary Number\n\n");
scanf("%ld",&n);
while(flag==1)
{
x=n%10;
s=s+x*power(i);
i=i+1;
n=n/10;
if(n==0)
flag=0;
}
printf("\nDecimal Equivalent = %d",s);
getch();
}
power(int i)
{
int j,p=1;
for(j=1;j<=i;j++)
p = p*2;
return(p);
}

0 comments :

C program for fibonacci series


#include<stdio.h>
#include<conio.h>
void main()
{
 int n;
 long int i;
 long int fibo(int n);
 clrscr();
 printf("Enter the limit:\n");
 scanf("%d",&n);
   i=fibo(n);
 printf("\nThe %dth Fibonacci number is %ld",n,i);
 getch();
}

long int fibo(int n)
{
 int old_no,currnt_no,sum,i;
   i=1;
   old_no=0;
   currnt_no=1;
   while(i<=n)
   {
      sum=old_no+currnt_no;
      old_no=currnt_no;
      currnt_no=sum;
      i++;
      printf("\n%d",sum);
   }
 return(sum);
}

Output:-

Enter the limit:

5

1
2
3
5
8
The 5th Fibonacci number is 8

0 comments :

C program for printing Pascal's Triangle


#include <stdio.h>
#include <conio.h>
void main()
{
int p[10][10];
int i,j,k;
clrscr();
printf("\nPascal's Triangle\n");
for(i=0;i<10;i++)
{
j=1;
p[i][0]=1;
p[i][i]=1;
while(j<i)
{
p[i][j]=p[i-1][j-1]+p[i-1][j];
j++;
}
}
for(i=0;i<10;i++)
{
j=10;
while(j>i)
{
printf("  ");
j--;
}
for(k=0;k<=i;k++)
{
printf("%4d",p[i][k]);
}
printf("\n\n");
}
getch();
}
Output:-

Pascal's Triangle
                    1                                                       
                  1   1                                                     
                1   2   1                                                   
             1   3   3   1                                                 
          1   4   6   4   1                                               
        1   5  10  10   5   1
      1   6  15  20  15   6   1                                           
    1   7  21  35  35  21   7   1                                         
  1   8  28  56  70  56  28   8   1                                       
1   9  36  84 126 126  84  36   9   1                                     

0 comments :

Eclipse shortcut keys



An integrated development environment (IDE) is a software application that provides comprehensive facilities to computer programmers for software development. An IDE normally consists of a source code editor, build automation tools and a debugger.
IDEs are designed to maximize programmer productivity by providing tight-knit components with similar user interfaces

Editors are an integral part of a programmer’s life. If you have good proficiency in using an editor thats a great advantage. For java developers there is huge list and some opular are Eclipse , Netbeans, MyEclipse. 
I use Eclipse as a my IDE. It is the leading development environment for Java

This post gives you information about various shortcut keys in Eclipse

You can use following keys for listing all shortcuts
CTRL + SHIFT + L

1.    Manage Files and Projects

Ctrl+N
Create new project using the Wizard
Ctrl+Alt+n
Create new project, file, class, etc.
Alt+f, then .
Open project, file, etc.
Ctrl+Shift+r
Open Ressource (file, folder or project)
Alt+Enter
Show and access file properties
Ctrl+s
Save current file
Ctrl+Shift+s
Save all files
Ctrl+w
Close current file
Ctrl+Shift+w
Close all files
F5
Refresh content of selected element with local file system

2.    Editor Window
Focus/ cursor must be in Editor Window for these to work.

F12
Jump to Editor Window
Ctrl+Page Down/Ctrl+Page Up
Switch to next editor / switch to previous editor
Ctrl+m
Maximize or un-maximize current Editor Window (also works for other Windows)
Ctrl+e
Show list of open Editors. Use arrow keys and enter to switch
Ctrl+F6/Ctrl+Shift+F6
Show list of open Editors. Similar to ctrl+e but switches immediately upon release of ctrl
Alt+Arrow Left/Alt+Arrow Right
Go to previous / go to next Editor Window
Alt+-
Open Editor Window Option menu
Ctrl+F10
Show view menu (features available on left vertical bar: breakpoints, bookmarks, line numbers, …)
Ctrl+F10, then n
Show or hide line numbers
Ctrl+Shift+q
Show or hide the diff column on the left (indicates changes since last save)

0 comments :