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 / java-tutorial-for-beginners.java
Last active June 4, 2024 10:51
Java Tutorial for Beginners
This is my Java note from caveofprogramming.com by John.
This is not a program.
All credit goes to John.
/*
|----------------------------------------
|Ten tips to make you a better programmer.
|----------------------------------------
*/
10. Learn to touch type.
9. Name variables and subroutines descriptively
@nijjwal
nijjwal / collection-java-tutorial.java
Last active March 24, 2024 14:48
collection-java-tutorial.java
//This is my note for Java Collection Framework course taught by John.
//Original credit: John from caveofprogramming.com
//All of his videos can be found in youtube.com
/**---------------------------------
| 1. ArrayList
|
*/---------------------------------
1.
-ArrayList class implements the class that is expandable.
@nijjwal
nijjwal / functions.js
Last active December 1, 2023 10:28
For this challenge you will determine the Run Length Encoding of a string.
<script>
/*
Have the function RunLength(str) take the str parameter being passed
and return a compressed version of the string using the Run-length
encoding algorithm. This algorithm works by taking the occurrence of
each repeating character and outputting that number along with a single
character of the repeating sequence. For example: "wwwggopp" would return
3w2g1o2p. The string will not contain any numbers, punctuation, or symbols.
*/
@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
@nijjwal
nijjwal / PrivateRoute.js
Created October 10, 2022 09:04
React - Private Route - Protecting Dashboard with a Wrapper Class
//Code for PrivateRoute.js
import React from "react";
import { Navigate } from "react-router-dom";
import { useAuth } from "../contexts/AuthContext";
export default function PrivateRoute({ children }) {
const { currentUser } = useAuth();
@nijjwal
nijjwal / useContext-App.js
Created October 10, 2022 01:15
useContext Hook # 3 sample code
import { useContext, createContext } from "react";
const moods = {
happy: ':)',
sad: ':('
};
const MoodContext = createContext(moods);
function App() {
@nijjwal
nijjwal / Signup.js
Last active October 9, 2022 09:36
react map
import React, { useState } from 'react'
export default function Signup() {
const people = [{name:'Jamie', age:37, id:1},{name:'Tyrion', age:36, id:2}];
const [users, updateUser] = useState(people);
//For Printing in cosole
people.map((person)=>{
console.log(person.name)
@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 / 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-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