Skip to content

Instantly share code, notes, and snippets.

View gunjanpatel's full-sized avatar

Gunjan Patel gunjanpatel

View GitHub Profile
#!/bin/sh
# Based on instructions found here: http://wiki.razuna.com/display/ecp/FFMpeg+Installation+on+CentOS+and+RedHat#FFMpegInstallationonCentOSandRedHat-InstallX264
if [ "`/usr/bin/whoami`" != "root" ]; then
echo "You need to execute this script as root."
exit 1
fi
cat > /etc/yum.repos.d/centos.repo<<EOF
@gunjanpatel
gunjanpatel / joomla git.md
Last active August 27, 2021 14:03
work with joomla git using terminal

Clone your forked repo in local.

Using Terminal

  1. For the very first time if you didn't configured remote repository then do it using this command.

     git remote add upstream git@github.com:joomla/joomla-cms.git
    
  2. Fetch changes from remote repository.

@gunjanpatel
gunjanpatel / get-menu-item-backend.php
Created July 11, 2016 05:10
Get article or content menu item from backend
<?php
// Get site menu - specially pass `site` argument as you are going to get site menu from backend.
$menu = JFactory::getApplication()->getMenu('site');
// Get menu item based on query
$menuItems = $menu->getItems('link', 'index.php?option=com_content&view=article&id=' . (int) $this->item->id);
@gunjanpatel
gunjanpatel / user.md
Created April 22, 2015 07:24
trigger joomla user plugin from your component

Using following code you can trigger any joomla user plugin event in your component

JPluginHelper::importPlugin('user', 'contactcreator');

JDispatcher::getInstance()->trigger(
	'onUserAfterSave', 
	array(
 $user, 
// original from: http://mashe.hawksey.info/2014/07/google-sheets-as-a-database-insert-with-apps-script-using-postget-methods-with-ajax-example/
// original gist: https://gist.github.com/willpatera/ee41ae374d3c9839c2d6
function doGet(e){
return handleResponse(e);
}
// Enter sheet name where data is to be written below
var SHEET_NAME = "Sheet1";
@gunjanpatel
gunjanpatel / IntersectionObserver.js
Last active May 8, 2021 05:03
Sticky Add to cart button for product page Using Intersection Observer - This will show add to car button when native button will be disappear.
document.addEventListener("DOMContentLoaded", function () {
var productCartButton = document.querySelector('.product-cart'), stickyAddToCartButton = document.querySelector('.sticky-add-to-cart'), previousTop = 0;
if ("IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype) {
let productCartButtonObserver = new IntersectionObserver(function (entries, observer) {
entries.forEach(function (entry) {
let addToCartButton = entry.target,
showstickyAddToCartButton = (entry.boundingClientRect.top < previousTop && entry.boundingClientRect.top < 0);
if (showstickyAddToCartButton) {
@gunjanpatel
gunjanpatel / sublime text 2
Last active September 28, 2020 18:01
sublime text 2 installation on Ubuntu.
How to install Sublime Text 2 on Ubuntu 12.04 (Unity)
April 28, 2012 by Jevin | 307 Comments
Sublime Text is an awesome text editor. If you’ve never heard of it, you should check it out right now.
I’ve made this tutorial because there’s no installer for the Linux versions of Sublime Text. While that’s not a real problem, I feel there is a cleaner way to go around this. Also, this post will show you how to integrate Sublime Text to Unity (which, I’m glad to report, has now matured into a fully functional user interface).
So let’s get on with this. Here is my how to install Sublime Text on Ubuntu tutorial.
@gunjanpatel
gunjanpatel / logistic_regression.py
Created July 5, 2019 06:25
Machine Learning with Python
import pandas as pd
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix
from sklearn.metrics import accuracy_score
# import warnings filter
from warnings import simplefilter
# ignore all future warnings
simplefilter(action='ignore', category=FutureWarning)
@gunjanpatel
gunjanpatel / zebra-print.py
Created May 8, 2019 09:59
Print script for zebra
#!/bin/env python
import socket, sys
PRINTER_IP = '10.1.11.121'
PORT = 9100
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((PRINTER_IP, PORT))
zpl = ''
zpl += '^XA'
@gunjanpatel
gunjanpatel / ffmpeg.md
Created October 30, 2018 09:59
FFMPEG scripts

Convert WMA to MP3

for file in *.wma; do ffmpeg -i "${file}"  -acodec libmp3lame -ab 192k "${file/.wma/.mp3}"; done