Skip to content

Instantly share code, notes, and snippets.

View anshuraj's full-sized avatar
🎯
Focusing

Anshu Raj anshuraj

🎯
Focusing
View GitHub Profile
@anshuraj
anshuraj / interactive tutorials
Last active April 17, 2019 05:51
Interactive Learning Tutorials
CSS Dinner: https://flukeout.github.io/
Flexbox Froggy: http://flexboxfroggy.com/
CSS Garder: http://cssgridgarden.com/
Open VIM: http://www.openvim.com/
Try Redis: http://try.redis.io/
@anshuraj
anshuraj / center-image.html
Created July 20, 2018 13:15
Center image horizontally and vertically inside a div.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div class="responsive-container">
const getQueryVariable = variable => {
const query = window.location.search.substring(1);
const params = query.split("&");
for (let i=0;i<params.length;i++) {
const pair = params[i].split("=");
if(pair[0] == variable) {
return pair[1];
}
}
return false;
@anshuraj
anshuraj / center-div.css
Created June 5, 2018 09:45
Center a div
.centered-div{
width: auto;
position: relative;
transform: translate(-50%, 0);
left: 50%;
}
@anshuraj
anshuraj / index.html
Last active June 5, 2018 07:28
Center image
<html>
<head>
<title>center image</title>
<link href="style.css">
</head>
<body>
<div class=frame>
<span class="helper"></span><img src="http://via.placeholder.com/300x150" />
</div>
<div class=frame>
@anshuraj
anshuraj / rename.py
Last active May 1, 2018 06:17
Script to rename uppercase first letter of all the files in a directory
import os
for filename in os.listdir("."):
os.rename(filename, filename[0].upper() + filename[1:])
@anshuraj
anshuraj / two_digits.js
Created May 1, 2018 06:11
input field restrict to 2 digits after decimal
$('.decimal').keypress(function (e) {
var character = String.fromCharCode(e.keyCode)
var newValue = this.value + character;
if(newValue.toString().split('.')[1].length > 2) {
e.preventDefault();
return false;
}
});
@anshuraj
anshuraj / search.js
Last active October 26, 2018 09:15
Javascript search in a list of string
search = (list, searchQuery) => {
var updatedList = list;
updatedList = updatedList.filter(function (item) {
return item.toLowerCase().search(
searchQuery.toLowerCase()) !== -1;
});
return updatedList;
}
@anshuraj
anshuraj / gist:fb287057636eee0edcc41e257e84dffd
Created April 11, 2018 06:33
Disable nginx startup on boot
sudo update-rc.d -f nginx disable
- Assuming php is already installed in the system, open a terminal and run php -i. Copy the output.
- Goto https://xdebug.org/wizard.php and paste the phpinfo output in the text box.
- Follow the instructions.