Skip to content

Instantly share code, notes, and snippets.

View sudarshann's full-sized avatar
💭
Modernizing

Sudarshan Anbazhagan sudarshann

💭
Modernizing
View GitHub Profile
@sudarshann
sudarshann / php-5.6-apache-mysql-ubuntu-22.04.sh
Last active August 12, 2023 08:35
These are just instructions with list of commands needs to be followed to install Lamp stack with Apache, php 5.6, mysql 5.6. This configured for prestashop 1.6 installation
# These are just instructions with list of commands needs to be followed to install Lamp stack with Apache, php 5.6, mysql 5.6. This configured for prestashop 1.6 installation
sudo add-apt-repository ppa:ondrej/php
sudo apt upgrade
sudo apt install apache2 php5.6 curl git unzip libapache2-mod-php5.6 php5.6-mysql php5.6-curl php5.6-cli php5.6-common php5.6-json php5.6-opcache php5.6-mysql php5.6-mbstring php5.6-zip php5.6-fpm php5.6-intl php5.6-simplexml php5.6-apcu php5.6-cli php5.6-memcached php5.6-pdo php5.6-zip php5.6-gd php5.6-xml php5.6-soap
sudo a2dismod php8.2
sudo a2enmod php5.6
sudo update-alternatives --config php
sudo a2enmod headers
@sudarshann
sudarshann / prepare-ubuntu-20-for-apache-php7.4-fpm-for-magento2.4.sh
Created September 20, 2021 11:24
Prepare Ubuntu 20.04 for Apache and PHP 7.4 FPM for magento 2.4
sudo apt update && sudo apt upgrade
sudo apt install software-properties-common && sudo add-apt-repository ppa:ondrej/php && sudo apt update
# https://devdocs.magento.com/guides/v2.4/install-gde/system-requirements.html
sudo apt install php7.4-fpm php7.4-common php7.4-mysql php7.4-xml php7.4-xmlrpc php7.4-curl php7.4-gd php7.4-imagick php7.4-cli php7.4-dev php7.4-imap php7.4-mbstring php7.4-soap php7.4-zip php7.4-bcmath php7.4-xsl php7.4-mysql php7.4-mbstring php7.4-intl -y
sudo apt install libsodium-dev
sudo pecl install -f libsodium
sudo apt install apache2
@sudarshann
sudarshann / bulk-transfer-repos.py
Created September 1, 2021 12:26 — forked from marcelkornblum/bulk-transfer-repos.py
Simple Python script to rip everything from BitBucket across to Github with minimal interaction
# heavily inspired by https://gist.github.com/rbellamy/3c5033ba605a090824e8
# gets everything from bitbucket and brings it across to GH, adding LFS where necessary for file size
# then archives everything brought over
#
# runs on Python 3; does clone --mirror and push --mirror, cleaning up after itself
#
# you need git-lfs installed on the local system
# also make sure you've got git credential caching set up https://help.github.com/articles/caching-your-github-password-in-git/
import json
@sudarshann
sudarshann / open-facebook-links-in-facebook-app.js
Last active February 27, 2023 18:20
This javascript code will help you to open facebook codes in facebook mobile app
const detectOs = {
getUserAgent: () => {
return navigator.userAgent;
},
getPlatform: () => {
return navigator.platform;
},
isIos: () => {
return /iPhone|iPad|iPod/.test(detectOs.getPlatform());
},
@sudarshann
sudarshann / wordpress-download-google-drive-image.php
Last active May 3, 2021 21:31
Simple wordpress php class to download external images to media
class downloadGoogleDriveImage {
public static function download_external_url_by_post_id($post_id, $meta_keys){
$result = [];
foreach($meta_keys as $meta_key){
$url = trim(get_post_meta($post_id, $meta_key, true));
if(empty($url)){
@sudarshann
sudarshann / countdown.js
Created March 11, 2021 07:34
Plain JS countdown timer. Read the time from that particular element and replaces with a count down in that same element
jQuery(document).ready(function(){
if(jQuery(".countdown h3 span") === 0 ){
return;
}
jQuery(".countdown h3 span").each(function(){
// Set the date we're counting down to
var element = jQuery(this);
var countDownDate = new Date(jQuery(this).text()).getTime();
// Update the count down every 1 second
@sudarshann
sudarshann / .htaccess
Last active December 21, 2020 10:32
Htaccess to block url based injections
<IfModule mod_rewrite.c>
# Block suspicious user agents and requests
RewriteCond %{HTTP_USER_AGENT} (libwww-perl|wget|python|nikto|curl|scan|java|winhttp|clshttp|loader) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} (<|>|'|%0A|%0D|%27|%3C|%3E|%00) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} (;|<|>|'|"|\)|\(|%0A|%0D|%22|%27|%28|%3C|%3E|%00).*(libwww-perl|wget|python|nikto|curl|scan|java|winhttp|HTTrack|clshttp|archiver|loader|email|harvest|extract|grab|miner) [NC,OR]
RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=http:// [OR]
RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=(\.\.//?)+ [OR]
RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=/([a-z0-9_.]//?)+ [NC,OR]
RewriteCond %{QUERY_STRING} \=PHP[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} [NC,OR]
apt update
apt upgrade
apt install apache2
a2enmod headers rewrite
systemctl restart apache2
sudo ufw allow in "Apache"
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
function copyToClipboard(textToCopy) {
var textArea;
function isOS() {
//can use a better detection logic here
return navigator.userAgent.match(/ipad|iphone/i);
}
function createTextArea(text) {
textArea = document.createElement('textArea');