Skip to content

Instantly share code, notes, and snippets.

View nijjwal's full-sized avatar
🎯
Focusing - Don't disturb

Nijjwal nijjwal

🎯
Focusing - Don't disturb
View GitHub Profile
@nijjwal
nijjwal / sql-injection-safe.php
Created March 31, 2015 03:20
sql-injection-prevention
<?php
require 'pdo.php';
//1. Create an instance of connection
$pdo_obj = new Connection();
//2. Connect to the server + db
try
@nijjwal
nijjwal / sqlinjection-prevention.php
Created March 31, 2015 10:12
Bind Parameters using bindValue method of PDO
<?php
require 'pdo.php';
//1. Create an instance of connection
//$pdo_obj = new Connection();
//2. Connect to the server + db
try
@nijjwal
nijjwal / sql-injection-information-schema.sql
Created April 1, 2015 21:27
SQL Injection - Information Schema Database
SELECT * FROM `eveil`.`student`
WHERE id = 1
UNION ALL
SELECT * FROM `bootcamp`.`student`
WHERE id = 1;
@nijjwal
nijjwal / delete-all-tables.sql
Created April 2, 2015 02:15
Delete all tables in SQL
begin
for i in (select * from tabs) loop
execute immediate ('drop table ' || i.table_name || ' cascade constraints');
end loop;
end;
/
@nijjwal
nijjwal / delete-all-veiws.sql
Created April 2, 2015 02:25
delete all views
1. Drop All Views
BEGIN
FOR i IN (SELECT view_name FROM user_views)
LOOP
EXECUTE IMMEDIATE('DROP VIEW ' || user || '.' || i.view_name);
END LOOP;
@nijjwal
nijjwal / gist:4d4614f561e3e18b0f9a
Created May 25, 2015 23:03
java collections for interview
1. Why do we need collection framework?
- If you want to represent 10,000 values, then declaring 10,000 variables
to represent those 10,000 values is worst programming practice.
Because readability of code is going to be hard. To overcome this problem
we should go for the next level - array concept. The biggest advantage of
array is we can represent huge number of values by using a single variable.
So, the readabilit of code is going to improve. Suppose, arrays concept is
not there, then we should go for the individual variables. To represent
10,000 values we will need 10,000 variables, then the readability of code
is going to go down.
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
@nijjwal
nijjwal / Employee.java
Last active December 16, 2017 11:24
HashMap Code. i) Find an employee whose id is 300. ii) Display all the employee information to show that map does not preserve insertion order. iii) Override toString method
import java.util.Map;
import java.util.HashMap;
public class Employee{
Integer empId;
String name;
@Override
public String toString()
{
@nijjwal
nijjwal / pom.xml
Created August 22, 2015 00:10
pom.xml file for generating a war file inside target folder which can be used by Jenkins to deploy it in a Tomcat Server.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>JenkinsEC2</groupId>
<artifactId>JenkinsEC2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
@nijjwal
nijjwal / disable-enter-key.html
Created January 3, 2016 22:46
Disable enter key in JavaScript
<!DOCTYPE html>
<html>
<head>
<title>Disable Key in JavaScript</title>
<script>
function noenter(e) {
//1. window is an object that represents an open window in a browser.
//2. event is an action that can be detected by javascript.
//Sometimes we want to execute a JavaScript when an event