Skip to content

Instantly share code, notes, and snippets.

View hitswa's full-sized avatar

Hitesh Kumar hitswa

View GitHub Profile
@hitswa
hitswa / cookies.js
Last active May 10, 2020 20:56
code to set and get cookies in browser using javascript
/* ***************************************
* COOKIE STORAGE
*
* Capacity: 4kb
* Browser: HTML4/5
* Accessible: From any window
* Expires: Wll last as per number of days provided / Manual Set
* Storage location: Browser and server
* Sent with requests: Yes
* *************************************** */
<?php
function numberToCurrency($number)
{
if(setlocale(LC_MONETARY, 'en_IN'))
return money_format('%.0n', $number);
else {
$explrestunits = "" ;
$number = explode('.', $number);
$num = $number[0];
@hitswa
hitswa / goodread_isbn.js
Last active July 20, 2019 15:21
fetching Goodread book data from API using ISBN with cross domain Access-Control-Allow-Origin CORP solution
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript">
goodRead('9382749004'); // not found
goodRead('0441172717'); // single author
goodRead('0552137030'); // multiple author
function goodRead(isbn) {
var key = "<your key>"; // replace with your key
@hitswa
hitswa / gist:d321654b184f1b9cb58d2e4d93bb87ac
Created April 3, 2017 08:32
getting full access to var/www/html folder
// Source: http://askubuntu.com/questions/162866/correct-permissions-for-var-www-and-wordpress
// First, you should ensure that your username is included in www-data group. If not, you can add your username as www-data group
sudo adduser $USER www-data
// After that, you should change the ownership of /var/www to your username
sudo chown $USER:www-data -R /var/www
// Next step, you should change permission to 755 (rwxr-xr-x), not recommend changing permission to 777 for security reason
sudo chmod u=rwX,g=srX,o=rX -R /var/www
@hitswa
hitswa / open-link.sh
Created June 12, 2015 00:58
opening a link via shell script
@hitswa
hitswa / lamp.sh
Last active March 30, 2022 10:42
Shell script to install LAMP + phpMyAdmin
echo 'installing LAMP Stack' &&
echo '=====================' &&
sudo apt-get update &&
echo 'installing Apache server' &&
sudo apt-get install -y apache2 &&
echo 'installing MySQL' &&
#will ask the password of root user two times (password=123456 i chose)
sudo apt-get -y install -y mysql-server php5-mysql &&
@hitswa
hitswa / prepare.sh
Last active August 29, 2015 14:22
shell script for fresh installed ubuntu copy
echo "Downloading GetDeb and PlayDeb" &&
wget http://archive.getdeb.net/install_deb/getdeb-repository_0.1-1~getdeb1_all.deb http://archive.getdeb.net/install_deb/playdeb_0.3-1~getdeb1_all.deb &&
echo "Installing GetDeb" &&
sudo dpkg -i getdeb-repository_0.1-1~getdeb1_all.deb &&
echo "Installing PlayDeb" &&
sudo dpkg -i playdeb_0.3-1~getdeb1_all.deb &&
echo "Deleting Downloads" &&
@hitswa
hitswa / everything.sh
Created March 7, 2015 06:46
Everything Search Engine alternative script for ubuntu
#!/bin/bash
t=$(mktemp)
locate "$1" | awk '{ printf "%4d\t\"%s\"\n", NR, $0 }' > $t
[[ -s $t ]] || { echo "No results found"; exit; }
rows=$(wc -l "$t" | cut -d' ' -f1)
if [[ $rows == 1 ]]; then
@hitswa
hitswa / .bash_aliases
Last active August 1, 2018 07:24
bash aliases file to be placed in home directory of ubuntu
alias cls='clear'
alias ipconfig='ifconfig'
alias install='sudo apt install -y'
alias uninstall='sudo apt purge -y'
alias update='sudo apt update'
alias upgrade='sudo apt upgrade'
alias majorupgrade='sudo apt-get dist-upgrade'
alias clean='sudo apt -f -y install && sudo apt autoremove -y && sudo apt -y autoclean && sudo apt -y clean'
alias dir='ls'
alias del='rm'