SEMrush

Friday, 15 March 2019

Codes 4 U: How to Invert an SVG image using CSS ?

Codes 4 U: How to Invert an SVG image using CSS ?: You can invert your svg easily by using following css code svg { -webkit-filter: invert(100%); /* safari 6.0 - 9.0 */ filter...

Monday, 10 December 2018

How to Check whether a string is match with Patterns or regex(Regular Expression) using JavaScript ?



    Here I would like to share a method for check whether a string is match with a regex(regular expression) using Java Script. This method will Output a boolean result(true or false).

The Method is ,

regex.test('string to check')

eg :- cosider a regix /^([a-z0-9]{5,})$/ (a string which contains number or letters and the minimum number of elements should be 5)
the code will be ,

/^([a-z0-9]{5,})$/.test('string to check');

Out Put :-

/^([a-z0-9]{5,})$/.test('abc1');      //will return false
/^([a-z0-9]{5,})$/.test('abc12');      //will return true
/^([a-z0-9]{5,})$/.test('abc123');      //will return true


Thursday, 6 December 2018

How to Select Immediate Next HTML Element Using JavaScript?



    Assume that you have two HTML tags and they are immediate neighbours , both of them are on the same line and if the first element have an id you then you can access the second element by using the first elements id.Here I will explain a method using JavaScript.Before that you should know about on which elements you can apply this and on which elements you can't.Conside the example below

tag1

  tag2....../tag2

  tag3....../tag3

  tag4....../tag4

/tag1

    On the above example you cannon't apply this methode for tag1 and tag2 ,because they are on different level (ie, here tag2 is child of tag1).You also not able to apply this method to tag2 and tag4 ,because even they are same level they are not immediate elements.Here you can apply this methode for tag2 and tag3 or tag3 and tag4 ,because they are on same level and immediate neighbour elements .

     So the Technique is to use JavaScript nextSibling Preperty.The Syntax is given below , assume that the id of tag1 is 'first element',then you can select tag2 by using the following code

Syntax:

document.getElementById('first-element').nextSibling


Wednesday, 5 December 2018

How to check the string only contain Numbers using Java Script ?



                          Text Box Sanitization is one of important think when we are developing a website or software. There we have a high chance for getting hacked or harmed by somebody outside if the software is un-sanitized. Sanitization is a process to secure the text boxes as well as the whole program from outside attacks.
                        Here I'm sharing some methods for text boxes(number type text boxes) to ensure that they only contain numbers. 
                       The Primary and most basic method is to add an attribute type with value number to your input text box.

ie, <input type='number'/>,

this is very effective but on some occasions which will not give the proper output.
                      Here I would like to share a method using Java Script ,

to check a string is number you can use the following code

var isNum = /^\d+$/.test(value);
if(isNum)
         alert(value + 'is a number'); 
else 
         alert(value + 'is not a number');  

                    here 'value' is the input test sample,if the input string only contains the digits this code will alert that is a number.else which alerts that is not a number
eg:-
value = 5                output :-  5 is a number
value = jkljk            output :-  jkljk is not a number
value = h5ht           output :-  h5ht is not a number
value = #%$@       output :-   #%$@ is not a number
which also detect the float number as not a number
 ie,
value = 2.5       output :-  2.5 is not a number

so in case of float numbers we use a different script


 var isFloatNumber = /^\d+\.\d+$/.test(value);

    if(isFloatNumber){
        alert(value + 'is a float number');
    }
    else {
         alert(value + 'is not a float number');   

    }

eg:-

value = 2.5             output :-  2.5 is a float number
value = 5                output :-  5 is not a float number
value = jkljk            output :-  jkljk is not a float number
value = h5ht           output :-  h5ht is not a float number

value = #%$@       output :-   #%$@ is not a float number

                                        

Sunday, 2 April 2017

Artificial Neural Network



Artificial Neural Network

Inspired by Biological Neural Network. This is used for Information Processing. In this a System of Neurons are Interconnected. It is Possible to Train a Neural Network.

History:-

In 1943 McCullough & Pitts Make Model based on Biological Mode.
Steps:-
1  1.    First We Draw a Neural Network.
    2.    Set the Values of Weights as Default
    3.    Create an Activation Function

Supervised Learning:-

Check the Output and Adjust the Weight, Until We Got the Correct Output. For Each Input We Check the Output.   



Saturday, 1 April 2017

Comparison Computer Neural Network v/s Biological Neural Network

1.Speed :- 



  • Biological Network is Slow in Processing Information ,It will Take a few Nano Seconds to Process an Information.
  • But a Computer Neural Network Take in Millie Seconds Range thus Computer Process Information a Million Time Faster.
2.Processing :-

  • Biological Neural Network Can Perform Parallel  Operations Massively.
  • Most Programs have Large no of Instructions and They Process Sequentially in Conventional Computer.
3.Size and Complexity :-

  • A Biological Neural Network have Large no of Computing Elements & Computing is not Restricted with in a Neuron.(no of Neurons in brain 10^11,total no of Neurons about 10 ^ 15.
  • It will Give the Brain to Understand & Perform the Complex Pattern Reorganization can't be Possible by Computer.
4.Storage :-

  • Biological Neural Networks Store Information in Strengths of Interconnection.
  • In Computer the Information is Stored in Memory ,Which is Addressed by Its Location 
  • In Computer the new Information stored by Overriding old Information.
  • But in Biological Neural Networks the new Information is Stored by Adjusting Strengths ,this Information in the Brain is Adaptable.
5.Fault Tolerance:-

  • Biological Neural Network Exhibits the Fault Tolerance Since the Information is Distributed.


Features of Biological Neural Network



Robustness or Fault Tolerance : -                                   
                               
    The Decay of Nerve Cells does not seem to affect the performance significantly.

Flexibility:-

The Network Automatically Adjust to a New Environment without using any Pre programmed Instruction.

Ability to Deal With A Variety of Situations :-
  
   The Network can deal with Information that is Fuzzy,Probabilistic,Noisy and Inconsistent.

Collective Computation:-
   The Network Perform Many Operations in Parallel and also a Given Task in Distributed Manner.

Friday, 31 March 2017

Different Computer Graphics Operations on Cube

Read Me :-


To compile the program, type
"g++ cube.cpp -lGL -lGLU -lglut"

========================KEY BOARD CONTROLS============================

ESC         : Close the Program
Arrow keys : Rotate the Cube
Shift + Arrow keys : Translate the cube
Ctrl + Up arrow : Expand the cube in all the 3 directions
Ctrl + Down arrow : Shrink the cube in all the 3 directions
========================================================================

Program : -

#include <GL\glut.h>

int r_y = 0; //x-axis rotation angle
int r_x = 0; //y-axis rotation angle
float t_x = 0,t_y = 0, scale = 1;//x-axis translation value,x-axis translation value,scale factor


void drawcube()
{

glClearColor(0.6f, 0.6f, 0.6f, 1.0f);
glBegin(GL_QUADS);

glColor3f(.3, 0, 1);

glVertex3i(1, 1, 1); //front
glVertex3i(1, -1, 1);
glVertex3i(-1, -1, 1);
glVertex3i(-1, 1, 1);

glColor3f(.2, 1, .8);

glVertex3i(1, 1, -1); //back
glVertex3i(1, -1, -1);
glVertex3i(-1, -1, -1);
glVertex3i(-1, 1, -1);

glColor3f(.7, .4, 1);

glVertex3i(1, 1, 1); //lside
glVertex3i(1, 1, -1);
glVertex3i(1, 0 - 1, -1);
glVertex3i(1, -1, 1);

glColor3f(1, .3, .8);

glVertex3i(-1, 1, 1); //rside
glVertex3i(-1, 1, -1);
glVertex3i(-1, 0 - 1, -1);
glVertex3i(-1, -1, 1);

glColor3f(.2, .5, .2);

glVertex3i(1, 1, 1); //top
glVertex3i(-1, 1, 1);
glVertex3i(-1, 1, -1);
glVertex3i(1, 1, -1);

glColor3f(.4, .4, .7);

glVertex3i(1, -1, 1); //bottom
glVertex3i(-1, -1, 1);
glVertex3i(-1, -1, -1);
glVertex3i(1, -1, -1);

glEnd();

//outline-----------------

glEnable(GL_LINE_SMOOTH);
glLineWidth(3.0);
glBegin(GL_LINES);
glColor3f(0,0,0);

glVertex3i(1, 1, 1); //front
glVertex3i(1, -1, 1);
glVertex3i(-1, -1, 1);
glVertex3i(-1, 1, 1);

glVertex3i(1, 1, -1); //back
glVertex3i(1, -1, -1);
glVertex3i(-1, -1, -1);
glVertex3i(-1, 1, -1);

glVertex3i(1, 1, 1); //lside
glVertex3i(1, 1, -1);
glVertex3i(1, 0 - 1, -1);
glVertex3i(1, -1, 1);

glVertex3i(-1, 1, 1); //rside
glVertex3i(-1, 1, -1);
glVertex3i(-1, 0 - 1, -1);
glVertex3i(-1, -1, 1);

glVertex3i(1, 1, 1); //top
glVertex3i(-1, 1, 1);
glVertex3i(-1, 1, -1);
glVertex3i(1, 1, -1);

glVertex3i(1, -1, 1); //bottom
glVertex3i(-1, -1, 1);
glVertex3i(-1, -1, -1);
glVertex3i(1, -1, -1);
glEnd();
glDisable(GL_LINE_SMOOTH);
glutPostRedisplay();

}

void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);

glLoadIdentity();
glTranslatef(t_x, t_y, 0);
glScalef(scale, scale, scale);
glRotatef(r_x, 1.0, 0.0, 0.0);
glRotatef(r_y, 0.0, 1.0, 0.0);
drawcube();

glutSwapBuffers();

}

void specialKeys(int key, int x, int y)// for rotating cube
{

int modifiers = glutGetModifiers();
//  Right arrow - increase rotation by 5 degree
switch (key)
{
case GLUT_KEY_RIGHT:r_y += 5; break;
case GLUT_KEY_LEFT:r_y -= 5; break;
case GLUT_KEY_UP:r_x += 5; break;
case GLUT_KEY_DOWN:r_x -= 5; break;

}

//  Request display update
glutPostRedisplay();

}

void key_press(unsigned char key, int x, int y)//for translating and scale
{
switch (key)
{
case 'a':t_x -= .1; break;
case 'f':t_x += .1; break;
case 's':t_y += .1; break;
case 'd':t_y -= .1; break;
case '1':scale += .1; break;
case '2':scale -= .1; break;
}
glutPostRedisplay();
}

int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowPosition(200, 20);
glutInitWindowSize(600, 600);
glutCreateWindow("Assignment PartA : CUBE");

glEnable(GL_DEPTH_TEST);
glutDisplayFunc(display);
glutSpecialFunc(specialKeys);
glutKeyboardFunc(key_press);
glMatrixMode(GL_PROJECTION);
glOrtho(-5, 5, -5, 5, -5, 5); //resize view cube size

glutMainLoop();
return 0;
}


Priority Scheduling Using C



#include <stdio.h>
#include <string.h>
struct well
{
int prio[2];
char name[10];
}d[10];
void main()
{
int n,k,i,j,r,l,m,q,e,f,v,s;
char a[50],b[50],c[50];
printf("enter no of data elements");
scanf("%d",&k);
printf("enter data and priority");
for(i=0;i<k;i++)
{
printf("data...priority");
scanf("%d",&d[i].name);
scanf("%d",&d[i].prio);
}
printf("enter the no of symbols");
scanf("%d",&n);
printf("enter the symbols");
q=strlen(a[i]);
while(q>0)
{
for(i=0;i<n;i++)
{
scanf("%c",&a[i]);
for(i=0;i<n;i++)
for(j=0;;)
{
for(l=0;l<10;l++)
if(a[i]==d[l].name)
{
r=d[l].prio;
break;
}
s=i+1;
for(l=0;l<10;l++)
if(a[s]==d[l].name)
{
m=d[l].prio;
break;
}
b[j]=0;
j++;
b[j]=a[i];
j=j+1;
if(r>m)
{
b[j]=0;
j++;
}
else if(r<m)
{
b[j]=1;
j++;
}
else
{
b[j]=2;
j++;
}
e=j;
}
e=e-1;
for(j=0;j<e;j++)
{
if(b[j]=='1')
{
v=j;
f=j;
while(b[f]!='0')
{
f--;
}
v=v+1;
for(j=f;v<e;j++,v++)
{
b[j]=b[v];
}
}
}
}

}
if(q==0)
printf("accepted");
else
printf("rejected");
}


Tuesday, 10 January 2017

Grid Properties



Grid Properties



Grid is a new concept in css ,which have a large application but less support.Which is used to Create Grid Layouts.
Usage:-
1).display : grid | inline-grid | sub-grid :-
  • grid :- generates a block level grid. Define the element as grid container abd establishes a new grid formatting context for it's contents.
  • Inline-grid:- generates an inline-level grid.
  • Sub-grid:-if your grid container itself a grid item ,you can use this property .
Note:- when Using this column,float,clear and vertical-align have no effect on a grid container.
2).grid-template-columns and grid-template-rows :-
  • grid-template-columns:- grid-template-columns used to set the width for the grid items.
    Syntax:- grid-template-columns : <track-size> | <line-name> <track-size>
  • grid-template-rows:- grid-template-rows used to set the height for the grid items.
    Syntax:- grid-template-rows : <track-size> | <line-name> <track-size>
3).grid-row-gap ,grid-column-gap and gap:-
  • grid-row-gap:- which is used to specify the gap between grid columns.
Syntax:- grid-row-gap : value;
  • grid-column-gap:- which is used to specify the gap between grid rows.
Syntax:- grid-column-gap : value;
  • grid-gap:-Which is used to specify grid-row-gap and grid-column-gap in common.


Support:-

Browser
Indirect Support
Direct Support
IE
(using -ms) 10

Fire Fox

52
Chrome

57
Safari,Android
No Support
No Support
Edje
(using -ms) 12

Opera

43