Skip to content

Instantly share code, notes, and snippets.

View hemantshekhawat's full-sized avatar
🎯
Focusing

Hemant Shekhawat hemantshekhawat

🎯
Focusing
View GitHub Profile
<?php
/**
* PHP Regex to validate a Twitter hashtag
*
* Useful for validating a text input (an HTML form in your CMS or custom application) that must be a valid Twitter hashtag.
* Valid examples: #a, #_, #_1, #_a, #1a, #áéìôü, #123hàsh_täg446
* Invalid examples: #1, ##hashtag, #hash-tag, #hash.tag, #hash tag, #hashtag!, (any hashtag that is more than 140 characters long, hash symbol included)
*
* Regex explanation:
* First, the lookahead assertion (?=.{2,140}$) checks the minimum and max length, as explained here http://stackoverflow.com/a/4223213/1441613
@hemantshekhawat
hemantshekhawat / mysql_db_sync
Created January 7, 2016 11:51 — forked from vasiliishvakin/mysql_db_sync
Simple bash script to sync remote mysql db to local
#!/bin/bash
LOCAL_DB=""
REMOTE_DB=""
LOCAL_USER="root"
LOCAL_PASS=""
REMOTE_USER="root"
REMOTE_PASS=''
@hemantshekhawat
hemantshekhawat / nginx-cors.conf
Created January 9, 2016 16:27 — forked from algal/nginx-cors.conf
nginx configuration for CORS (Cross-Origin Resource Sharing), with an origin whitelist, and HTTP Basic Access authentication allowed
#
# A CORS (Cross-Origin Resouce Sharing) config for nginx
#
# == Purpose
#
# This nginx configuration enables CORS requests in the following way:
# - enables CORS just for origins on a whitelist specified by a regular expression
# - CORS preflight request (OPTIONS) are responded immediately
# - Access-Control-Allow-Credentials=true for GET and POST requests
@hemantshekhawat
hemantshekhawat / hhvm_magento_setup.md
Created April 22, 2016 07:58 — forked from tegansnyder/hhvm_magento_setup.md
HHVM Magento Server Setup

I've had the opertunity to try a variety of different server configurations but never really got around to trying HHVM with Magento until recently. I thought I would share a detailed walkthrough of configuring a single instance Magento server running Nginx + Fast CGI + HHVM / PHP-FPM + Redis + Percona. For the purpose of this blog post I'm assuming you are using Fedora, CentOS, or in my case RHEL 6.5.

Please note: I'm 100% open to suggestions. If you see something I did that needs to be done a different way, please let me know. I haven't included my Perconca my.conf file yet. I will shortly. Also I plan on trying this same test with HHVM 3.3 and PHP 7.

Install the EPEL, Webtatic, and REMI repos

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
@hemantshekhawat
hemantshekhawat / onepage.phtml
Created June 16, 2016 22:55 — forked from ashsmith/onepage.phtml
Track each step of the Magento onepage checkout in Google Analytics with this simple Javascript addition to [package]/[theme]/template/checkout/onepage.phtml just add it to the bottom of that file and follow up by configuring with Google Analytics goals
<script type="text/javascript">
Checkout.prototype.gotoSection = Checkout.prototype.gotoSection.wrap(function(parentMethod, section, reloadProgressBlock) {
// Call parent method.
parentMethod(section, reloadProgressBlock);
var _gaq = _gaq || [];
try {
// push current checkout section to google analytics if available.
@hemantshekhawat
hemantshekhawat / scs-tutorial-linux-shared-hosting-server.sh
Created November 28, 2016 11:35 — forked from stewartadam/scs-tutorial-linux-shared-hosting-server.sh
CentOS 7 shared hosting server setup script based on the SCS Shared Linux Hosting Server Security tutorial at Concordia University (2016) - discussion about security principles in the context of a shared hosting server.
#!/bin/sh
#
# Usage:
# This script will establish a basic shared hosting server running DNS, Web (HTTP), DB (SQL) and e-mail (SMTP/IMAP) services.
#
# This script doesn't include usage information on adding new user accounts and setting up mail inboxes; for that, please see my
# CentOS 5 server setup tutorial: http://www.firewing1.com/howtos/servers/centos5/getting_started
#
# This configuration is very similar to my previously documented CentOS 5 server setup, but has been ported to take advantage
# of the new features in CentOS 7.
@hemantshekhawat
hemantshekhawat / Laravel PHP7 LEMP AWS.md
Created January 3, 2017 08:03 — forked from santoshachari/Laravel PHP7 LEMP AWS.md
Laravel 5.x on Ubuntu 14.x, PHP 7.x, Nginx 1.9.x

#Steps to install latest Laravel, LEMP on AWS Ubuntu 14.4 version. This tutorial is the improvised verision of this tutorial on Digitalocean based on my experience.

Install PHP 7 on Ubuntu

Run the following commands in sequence.

sudo apt-get install -y language-pack-en-base
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install zip unzip
@hemantshekhawat
hemantshekhawat / .htaccess
Created June 1, 2017 12:55 — forked from Eomerx/.htaccess
.htaccess
# Apache Server Configs v2.14.0 | MIT License
# https://github.com/h5bp/server-configs-apache
# (!) Using `.htaccess` files slows down Apache, therefore, if you have
# access to the main server configuration file (which is usually called
# `httpd.conf`), you should add this logic there.
#
# https://httpd.apache.org/docs/current/howto/htaccess.html.
# ######################################################################
@hemantshekhawat
hemantshekhawat / GearmanInstall.sh
Created August 31, 2017 06:22
Gearman Server With Linux Machine
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install gcc autoconf bison flex libtool make libboost-all-dev libcurl4-openssl-dev curl gperf libevent-dev uuid-dev libmysqlclient-dev
cd ~
wget https://launchpad.net/gearmand/1.2/1.1.12/+download/gearmand-1.1.12.tar.gz
tar -xvf gearmand-1.1.12.tar.gz
cd gearmand-1.1.12
./configure
@hemantshekhawat
hemantshekhawat / Apache_PHP.sh
Last active June 3, 2021 07:51
Gearman Job Server for CentOS 7
###### Install Apache/httpd and PHP
# Before you begin any installation, make sure that your software is up to date:
sudo yum update
#Install Apache:
sudo yum install httpd
#Start Apache:
sudo systemctl start httpd.service
#Set Apache to start on server boot:
sudo systemctl enable httpd.service