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 / 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 / .dart
Created May 23, 2020 02:51
sample dart code to for dart pad
List<String> names = ['Angela','John','Nijjwal','Jane'];
@nijjwal
nijjwal / gist:8da28c9acff8baf45922e4c34ed77041
Last active March 9, 2020 01:25
update ec2, install apache web server, start apache, and every time ec2 starts start apache web server, and create an index.html file with some content in the web root directory
#!/bin/bash
yum update -y
yum install httpd -y
service httpd start
chkconfig on
cd /var/www/html
echo "<html><body>us-second-server</body></html>">index.html
@nijjwal
nijjwal / .json
Created March 8, 2020 05:17
AWS Make All Object Public inside a Bucket after allowing public access to the bucket
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::nijjwal.com/*"
}
@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 / 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 / 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()
{
<?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>