Showing posts from June, 2014

Auto proxy changer application code in VB .Net

The code given here is for making simple app in VB .Net which will read a proxy address from file specified in path field and then automatically change the proxy settings of PC to next proxy address from file after specified time amount. Note that file contains list of proxy addresses with port number in format as given below …………… ……………. i.e., ip address and port number. Form1.vb ----------------------------------------------------------------------------------Imports SystemImports System.Runtime.InteropServicesImports System.IOImports Microsoft.VisualBasicImports System.TimersPublic Class Form1    Dim FILE_NAME As String = "C:UsersDellDocuments12.txt"    Dim label As String    Public proxy(2000) As String    Public index As Integer = 0    Public max_proxys As Integer=0    Dim a As String    Dim start_check As Integer = 0    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load           End Sub    Priv

Code for setting webview in android

/**/package com.shubham.webviewclientdemo;import;import;import android.os.Bundle;import android.view.KeyEvent;import android.view.View;import android.webkit.WebView;import android.webkit.WebViewClient;import android.widget.ProgressBar;/* * Demo of creating an application to open any URL inside the application and clicking on any link from that URlshould not open Native browser but  that URL should open in the same screen.- Load WebView with progress bar */public class WebViewClientDemoActivity extends Activity {    /** Called when the activity is first created. */       WebView web;    ProgressBar progressBar;    StartAppAd startAppAd;    @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.main);        web = (WebView) findViewById(;        progressBar = (ProgressBar) findViewById(;        web.setWebViewCl

Matlab code to convert image to binary numbers and convert back to original

% Reading image fileim=imread('C:UsersDellPictures17.jpg');   % converting image to binary numbersc=dec2bin(im,8);% saving result to filefid = fopen('magic5.txt', 'w+');fwrite(fid,c); fclose(fid);disp(c);%converting image back to decimal and displaying it.d=reshape(uint8(bin2dec(c)),size(im) );image(d); [AMAZONPRODUCTS asin=”0470767855″]

PHP code to delete all files in folder

<?php$files = glob('images/*'); // get all file namesforeach($files as $file){ // iterate files  if(is_file($file))    unlink($file); // delete file}?>  

Code for handling exceptions in C++

#include <iostream>using namespace std;double division(int a, int b){   if( b == 0 )   {      throw "Division by zero condition!";   }   return (a/b);}int main (){int x,y;double z;cout<<"Enter value of x and yn";cin>>x>>y;   try    {     z = division(x, y);     cout << z<<"n";    }catch (const char* msg){     cout << msg << endl;   }   return 0;}    

Program code demonstrating use of abstract class in C++

#include<iostream>using namespace std;class abstractinterface {   public:   virtual void numbers()=0;   void input();   int a, b; };void abstractinterface::input()  {    cout<< "Enter the numbersn";    cin>>a>>b;  }class add : public abstractinterface {  public:  void numbers()   {     int sum;     sum=a+b;     cout<<"sum is "<<sum<<"n";   } };class sub : public abstractinterface {   public:   void numbers()    {     int diff;     diff=a-b;     cout<<"diff is "<<diff<<"n";    } };int main() {  add obj1;  obj1.input();  obj1.numbers();  sub obj2;  obj2.input();  obj2.numbers();return 0; }  

Simple visitor counter in php

<?php    $file = file_get_contents("count.txt");    $visitors = $file;    $visitorsnew = $visitors+1;    $filenew=fopen("count.txt","w");    fwrite ($filenew,$visitorsnew);    echo "you've had $visitorsnew visitors.";    ?>  

PHP code for handling file uploads

<?php//properties of the uploaded file$name= $_FILES["myfile"]["name"];$type= $_FILES["myfile"]["type"];$size= $_FILES["myfile"]["size"];$temp= $_FILES["myfile"]["temp_name"];$error= $_FILES["myfile"]["error"];if ($error > 0)    die("Error uploading file! code $error.");else   {    if($type=="image/png" || $size > 2000000)//condition for the file    {    die("Format  not allowed or file size too big!");    }    else    {     move_uploaded_file($temp, "uploaded/" .$name);     echo "Upload complete!";     }}?>  

Simple user registration code in php using md5 encryption for password encryption.

  <?php       echo "<h1> Register</h1>";    $submit = $_POST['submit'];    //form data    $fullname = strip_tags($_POST['fullname']);    $username = strtolowe(strip_tags($_POST['username ']));    $password = strip_tags($_POST['password ']);    $repeatpassword =strip_tags($_POST['repeatpassword ']);    $date = date("y-m-d");          if($submit)    {        $connect = mysql_connect ("localhost","root","");        mysql_select_db("phplogin");        $namecheck = mysql_query("SELECT username FROM users WHERE username ='$username'");           $count = mysql_num_rows($namecheck);               if($count!=0)            {            die("Username already taken!");            }     // check for existance               if($fullname && $username && $password && $repeatpassword)        {                       if($password == $repea