[email protected]
Check If Web Page Is In An Iframe
function checkIframe() {
if (window.top != window.self) {
console.log("This webpage has been used in an iframe!");
} else {
console.log("This webpage has not been used in an iframe.");
}
}
function checkIframe() {
if (window.top != window.self) {
console.log("This webpage has been used in an iframe!");
} else {
console.log("This webpage has not been used in an iframe.");
}
}
[email protected]
Select Parent Element Of An Element In Vanilla JS
var parent = document.querySelector("#element").parentElement;
var parent = document.querySelector("#element").parentElement;
[email protected]
Center Everything In A Div
<style>
@import url('https://fonts.googleapis.com/css2?family=Poppins:[email protected]&display=swap');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
nav {
background-color: #000;
color: #fff;
height: 100px;
position: relative;
}
nav > div > ul {
align-items: center;
height: 100px;
position: absolute;
right: 100px;
top: 0;
display: grid;
grid-template-columns: 100px 100px 100px 100px;
grid-gap: 20px;
list-style-type: none;
}
nav > div > ul > a > li {
color: #fff;
text-decoration: none;
text-align: center;
}
nav > .logo {
position: absolute;
top: 50%;
left: -50px;
width: 230px;
color: #fff;
transform: translateY(-50%);
}
nav > .logo > span {
position: absolute;
right: 0;
top: 50%;
transform: translateY(-50%);
}
nav > div > ul > a {
width: calc(auto + 20px);
border: 1px solid grey;
padding: 10px;
border-radius: 20px;
text-decoration: none;
}
nav > div > ul > a:hover {
width: calc(auto + 20px);
border: 1px solid #007bff;
padding: 10px;
border-radius: 20px;
text-decoration: none;
}
nav > div {
display: inline-block;
}
</style>
<nav>
<div class="logo"><img src="https://freekode.centeltech.com/media/profile_pics/imgo_JNnnH5k.png" alt=""><span>FreeKode</span></div>
<div>
<ul>
<a href="#"><li>Home</li></a>
<a href="#"><li>About</li></a>
<a href="#"><li>About</li></a>
<a href="#"><li>Contact</li></a>
</ul>
</div>
</nav>
<style>
@import url('https://fonts.googleapis.com/css2?family=Poppins:[email protected]&display=swap');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
nav {
background-color: #000;
color: #fff;
height: 100px;
position: relative;
}
nav > div > ul {
align-items: center;
height: 100px;
position: absolute;
right: 100px;
top: 0;
display: grid;
grid-template-columns: 100px 100px 100px 100px;
grid-gap: 20px;
list-style-type: none;
}
nav > div > ul > a > li {
color: #fff;
text-decoration: none;
text-align: center;
}
nav > .logo {
position: absolute;
top: 50%;
left: -50px;
width: 230px;
color: #fff;
transform: translateY(-50%);
}
nav > .logo > span {
position: absolute;
right: 0;
top: 50%;
transform: translateY(-50%);
}
nav > div > ul > a {
width: calc(auto + 20px);
border: 1px solid grey;
padding: 10px;
border-radius: 20px;
text-decoration: none;
}
nav > div > ul > a:hover {
width: calc(auto + 20px);
border: 1px solid #007bff;
padding: 10px;
border-radius: 20px;
text-decoration: none;
}
nav > div {
display: inline-block;
}
</style>
<nav>
<div class="logo"><img src="https://freekode.centeltech.com/media/profile_pics/imgo_JNnnH5k.png" alt=""><span>FreeKode</span></div>
<div>
<ul>
<a href="#"><li>Home</li></a>
<a href="#"><li>About</li></a>
<a href="#"><li>About</li></a>
<a href="#"><li>Contact</li></a>
</ul>
</div>
</nav>
[email protected]
Center Everything In A Div
div {
display: flex;
justify-content: center;
align-items: center;
}
div {
display: flex;
justify-content: center;
align-items: center;
}
justacode
Git Create Repo & Push To It
Create a new repository in GitHub via this link: https://github.com/new
$ git init
$ git add .
$ git commit -m "First Commit"
$ git branch -M main
$ git remote add origin https://github.com/username/repo.git
$ git push -u origin main
Create a new repository in GitHub via this link: https://github.com/new
$ git init
$ git add .
$ git commit -m "First Commit"
$ git branch -M main
$ git remote add origin https://github.com/username/repo.git
$ git push -u origin main
justacode
Download File From Remote EC2 Server SCP
$ sudo scp -i ./pemfile.pem [email protected]:~/file.txt ./file.txt
# ./pemfile.pem is the pem key to accessing your server. Make sure no one other than you and your team know about it.
# user is the user which has access to the file you want to download onto your local machine. Example: ubuntu.
# ec2-x-x-xx-xx.location.compute.amazonaws.com is the EC2 link for the file you want to download.
# ~/file.txt is the path for the file you want to download in the remote EC2 server.
# ./file.txt is the name and the path where the file should download on your local computer.
$ sudo scp -i ./pemfile.pem [email protected]:~/file.txt ./file.txt
# ./pemfile.pem is the pem key to accessing your server. Make sure no one other than you and your team know about it.
# user is the user which has access to the file you want to download onto your local machine. Example: ubuntu.
# ec2-x-x-xx-xx.location.compute.amazonaws.com is the EC2 link for the file you want to download.
# ~/file.txt is the path for the file you want to download in the remote EC2 server.
# ./file.txt is the name and the path where the file should download on your local computer.
justacode
Install NodeJS Via The Terminal On Ubuntu
$ sudo apt-get install curl
$ curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
$ sudo apt-get install nodejs
# Check if installed correctly:
$ node -v
$ npm -v
$ sudo apt-get install curl
$ curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
$ sudo apt-get install nodejs
# Check if installed correctly:
$ node -v
$ npm -v
[email protected]
Restart PostgreSQL On Ubuntu
sudo service postgresql restart
// Or
sudo systemctl restart postgresql.service
sudo service postgresql restart
// Or
sudo systemctl restart postgresql.service