Sunday, November 26, 2017

How do I delete a Git branch both locally and remotely?








To delete Locally - (Normal),
 
git branch -d my_branch
 
If your branch in rebasing/merging progress and that was not done properly means, you will get an error Rebase/Merge in progress so in that case, you won't be able to delete your branch.

So either your need to solve rebasing/merging otherwise you can do force Delete by using,

git branch -D my_branch
 
To delete in Remote:

git push --delete origin my_branch
 
can do the same using ,

git push origin :my_branch   # easy to remember both will do the same.

Wednesday, November 22, 2017

hooks in codeigniter

What is hooks in codeigniter and how it works

CodeIgniter’s Hooks feature provides a means to tap into and modify the inner workings of the framework without hacking the core files. When CodeIgniter runs it follows a specific execution process, diagramed in the Application Flow page. There may be instances, however, where you’d like to cause some action to take place at a particular stage in the execution process. For example, you might want to run a script right before your controllers get loaded, or right after, or you might want to trigger one of your own scripts in some other location.

Hook Points

The following is a list of available hook points.
  • pre_system Called very early during system execution. Only the benchmark and hooks class have been loaded at this point. No routing or other processes have happened.
  • pre_controller Called immediately prior to any of your controllers being called. All base classes, routing, and security checks have been done.
  • post_controller_constructor Called immediately after your controller is instantiated, but prior to any method calls happening.
  • post_controller Called immediately after your controller is fully executed.
  • display_override Overrides the _display() method, used to send the finalized page to the web browser at the end of system execution. This permits you to use your own display methodology. Note that you will need to reference the CI superobject with $this->CI =& get_instance() and then the finalized data will be available by calling $this->CI->output->get_output().
  • cache_override Enables you to call your own method instead of the _display_cache() method in the Output Library. This permits you to use your own cache display mechanism.
post_system Called after the final rendered page is sent to the browser, at the end of system execution after the finalized data is sent to the browser.





INTERVIEW QUESTIONS .....

 

What is sql injection ? ( top interview Question)

What is sql injection ?

SQL injection is a code injection technique that might destroy your database.
SQL injection is one of the most common web hacking techniques.
SQL injection is the placement of malicious code in SQL statements, via web page input.


What is the difference between primary key and unique key ?
Primary Key
Unique Key
Definition
Primary key is a type of a unique key. This is the key that is allowed to migrate to other entities to define the relationships that exist among the entities.
A unique key is a set of zero, one, or more attributes. The value(s) of these attributes are required to be unique for each tuple (row) in a relation. The value, or combination of values, of unique key attributes for any tuple should not be repeated for any other tuple in that relation.
Used in
Relational Database Management Systems such as MySQL, Oracle, etc.
Relational Database Management Systems such as MySQL, Oracle, etc.
Null Values
Does not accept any null values
Accepts only one null value in the table
Type of Index
Is a clustered index and data in the database table is physically organized in the sequence of clustered index           
Is a unique non-clustered index
Number of Keys allowed
Only one primary key in a table
Can have more than one unique key in a table
Convertible
Can be made into a foreign key into another table
Can be made into a foreign key into another table

What is the difference between char and varchar  ?
CHAR Data Type is a Fixed Length Data Type. For example if you declare a variable/column of CHAR (10) data type, then it will always take 10 bytes irrespective of whether you are storing 1 character or 10 character in this variable or column. And in this example as we have declared this variable/column as CHAR(10), so we can store max 10 characters in this column.
On the other hand VARCHAR is a variable length Data Type. For example if you declare a variable/column of VARCHAR (10) data type, it will take the no. of bytes equal to the number of characters stored in this column. So, in this variable/column if you are storing only one character then it will take only one byte and if we are storing 10 characters then it will take 10 bytes. And in this example as we have declared this variable/column as VARCHAR (10), so we can store max 10 characters in this column.
if you like our post you can contribute us by Click Here

What is csrf and xss clean?

          CSRF :

Cross-site request forgeries are a type of malicious exploit whereby unauthorized commands are performed on behalf of an authenticated user.

Laravel automatically generates a CSRF "token" for each active user session managed by the application. This token is used to verify that the authenticated user is the one actually making the requests to the application

XSS clean :

the attack is basically a type of code injection attack which is made possible by incorrectly validating user data, which usually gets inserted into the page through a web form or using an altered hyperlink. The code injected can be any malicious client-side code, such as JavaScript, VBScript, HTML, CSS, Flash, and others. The code is used to save harmful data on the server or perform a malicious action within the user’s browser.

Unfortunately, cross-site scripting attacks occurs mostly, because developers are failing to deliver secure code. Every PHP programmer has the responsibility to understand how attacks can be carried out against their PHP scripts to exploit possible security vulnerabilities. Reading this article, you’ll find out more about cross-site scripting attacks and how to prevent them in your code.

Preventing Cross-Site Scripting Attacks

  •     Data Validation

  •     Data Sanitization

  •     Output Escaping

  • Htmlspecialchars :

    • The htmlspecialchars() function converts some predefined characters to HTML entities.

  • HTML entities

    • The htmlentities() function converts characters to HTML entities.

  • Strip_tags

    • The strip_tags() function strips a string from HTML, XML, and PHP tags.

    • Note: HTML comments are always stripped. This cannot be changed with the allow parameter.

    • Note: This function is binary-safe.

      --------------------------------------------------------------------------------------------

       

Trim()

The trim() function removes whitespace and other predefined characters from both sides of a string.


ltrim() - Removes whitespace or other predefined characters from the left side of a string

rtrim() - Removes whitespace or other predefined characters from the right side of a string

Monday, November 20, 2017

Change an HTML5 input's placeholder color with CSS

There are three different implementations: pseudo-elements, pseudo-classes, and nothing.
  • WebKit, Blink (Safari, Google Chrome, Opera 15+) and Microsoft Edge are using a pseudo-element: ::-webkit-input-placeholder
  • Mozilla Firefox 4 to 18 is using a pseudo-class: :-moz-placeholder (one colon). 
  • Mozilla Firefox 19+ is using a pseudo-element: ::-moz-placeholder, but the old selector will still work for a while. 
  • Internet Explorer 10 and 11 are using a pseudo-class: :-ms-input-placeholder
Internet Explorer 9 and lower does not support the placeholder attribute at all, while Opera 12 and lower do not support any CSS selector for placeholders.
The discussion about the best implementation is still going on. Note the pseudo-elements act like real elements in the Shadow DOM. A padding on an input will not get the same background color as the pseudo-element.

So we need separate rules for each browser. Otherwise the whole group would be ignored by all browsers.

::-webkit-input-placeholder { /* WebKit, Blink, Edge */
    color:    #909;
}
:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
   color:    #909;
   opacity:  1;
}
::-moz-placeholder { /* Mozilla Firefox 19+ */
   color:    #909;
   opacity:  1;
}
:-ms-input-placeholder { /* Internet Explorer 10-11 */
   color:    #909;
}
::-ms-input-placeholder { /* Microsoft Edge */
   color:    #909;
}
<input placeholder="php999 is great!">

GitHub repository using Git Bash command

  To add a project to a GitHub repository using Git Bash command line, you can follow these steps: Create a new repository on GitHub by logg...