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 / 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.
@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 / 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 / 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 / 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-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 / sql-vulnerable-code-pdo.php
Last active May 25, 2020 02:20
PHP - SQL Injection - 1
<?php
require 'pdo.php';
//1. Create an instance of connection
$pdo_obj = new Connection();
//2. Connect to the server + db
try
@nijjwal
nijjwal / sql-vulnerable-code-pdo.php
Last active May 25, 2020 02:20
PHP - SQL Injection - 1
<?php
//This class helps to connect to the
class Connection{
public function connect()
{
return new PDO('mysql:host=localhost; dbname=sqlinjection2','root','root');
}
}
@nijjwal
nijjwal / common-errors.java
Created January 28, 2015 05:52
Java Common Errors
1. Null Pointer Exception.
- If you are trying to access an object that does not exist.
For example, accesing an object whose pkid id 1 , but that has already been deleted will
result in Null Pointer Exception.
@nijjwal
nijjwal / javafx-tutorial.java
Last active August 29, 2015 14:14
javafx-tutorial.java
/**
|------------------------------------
|1. Introductiona and Installation
|------------------------------------
*/
1. A lot of people use NetBeans with JavaFX.
2. You will need Java 7 for this. You will need JDK 7 or later.