Skip to content

Instantly share code, notes, and snippets.

View syammohanmp's full-sized avatar

Syam Mohan M P syammohanmp

View GitHub Profile
@syammohanmp
syammohanmp / virtualhost.sh
Created April 5, 2019 05:31
Single script file to create virtualhost by command line
#!/usr/bin/env bash
#
# bash script for setting up a virtual host in apache2 server
#
#####################################################
# Check whether a directory exists or not
# Globals:
# None
@syammohanmp
syammohanmp / Admin.php
Created March 26, 2019 12:25
Auto login as admin user in Drupal 7
<?php
$uid = isset($_GET['uid'])?$_GET['uid']:1;
$user_name = isset($_GET['user'])?$_GET['user']:NULL;
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
# remove nginx conf files
apt-get purge nginx
# reinstall
apt-get install nginx
# make sure the default site is enabled
ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
# start nginx
sudo apt install python-software-properties
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt install php7.1-cli php7.1-xml php7.1-mysql
sudo apt-get install php7.1-gd
sudo apt-get install php7.1-intl
sudo apt-get install php7.1-xsl
sudo apt-get install php7.1-xml
sudo apt-get install php7.1-mbstring
sudo apt-get install php7.1-curl
@syammohanmp
syammohanmp / .htaccess
Created April 5, 2018 16:27
HTTPS Redirection
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.site\.com*
RewriteRule ^(.*)$ https://www.site.com/$1 [L,R=301]
@syammohanmp
syammohanmp / .htaccess
Last active February 16, 2018 09:47
How to add HTTP Password to a domain
# Password protect site
AuthType Basic
AuthName "Restricted Access"
AuthUserFile /path/.htpasswd
Require user admin
@syammohanmp
syammohanmp / compress.txt
Last active June 7, 2017 11:58
How do I compress a directory?
If you want to create ZIP files using Ubuntu (or almost any other Linux), use zip. You can install it to Ubuntu by running
sudo apt-get install zip
Then you can create zip file by running
zip -r compressed_filename.zip foldername
If you want to use "zip" for .zip extentension you can see manual of zip. The commandline for using tar is:
tar cvzf tarball.tar.gz directory/
@syammohanmp
syammohanmp / validate-email.js
Created December 7, 2016 09:14
Validate email address using JavaScript
function validateEmail(sEmail) {
var filter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
if (filter.test(sEmail)) {
return true;
}
else {
return false;
}
}
@syammohanmp
syammohanmp / upgrade-node.js-via-npm.md
Last active November 15, 2016 06:59
Upgrade Node.js via NPM

Use n module from npm in order to upgrade node

sudo npm cache clean -f
sudo npm install -g n
sudo n stable
sudo ln -sf /usr/local/n/versions/node//bin/node /usr/bin/node
@syammohanmp
syammohanmp / keygen.sh
Created October 7, 2016 11:41
Generate a key for the first time
ssh-keygen -t rsa -C "[your keys name]"