Skip to content

Instantly share code, notes, and snippets.

Avatar

Gunjan Patel gunjanpatel

View GitHub Profile
View google_script.gs
// 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 / useful_commands_to_use_in_shell.md
Created Apr 17, 2020 — forked from jcarolinares/useful_commands_to_use_in_shell.md
This is a simple guide for non-pro bash users to do random but annoying tasks in just seconds
View useful_commands_to_use_in_shell.md

Useful commands to use in Shell or others:

This is a simple guide for non-pro bash users to do random but annoying tasks in just seconds

Your boss will be happy and you'll be less stressed ;)

PDFs

Search a phrase or keyword in multiple PDF:

@gunjanpatel
gunjanpatel / logistic_regression.py
Created Jul 5, 2019
Machine Learning with Python
View logistic_regression.py
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
Print script for zebra
View zebra-print.py
#!/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'
View ffmpeg.md

Convert WMA to MP3

for file in *.wma; do ffmpeg -i "${file}"  -acodec libmp3lame -ab 192k "${file/.wma/.mp3}"; done
@gunjanpatel
gunjanpatel / 01-README.md
Last active Jun 13, 2018
JQuery plugin to observe appearance of the element. Intersection observer using jquery.
View 01-README.md

Usage

$('#observeMe').appearanceObserver({
    onAppeared: function () {
        // I am appeared callback
    },
    onDisappeared: function () {
        // I am disappeared callback
    }
});
@gunjanpatel
gunjanpatel / IntersectionObserver.js
Last active May 8, 2021
Sticky Add to cart button for product page Using Intersection Observer - This will show add to car button when native button will be disappear.
View IntersectionObserver.js
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 / flags.twig
Created Apr 12, 2018
Flag icon css svg
View flags.twig
This file has been truncated, but you can view the full file.
{% macro icon() %}
<svg xmlns="http://www.w3.org/2000/svg" style="display:none">
<symbol id="flag-icon-css-ad" viewBox="0 0 640 480">
<path fill="#d0103a" d="M0 0h640v480H0z"/>
<path fill="#fedf00" d="M0 0h435.2v480H0z"/>
<path fill="#0018a8" d="M0 0h204.8v480H0z"/>
@gunjanpatel
gunjanpatel / backdrop-gradient-css
Last active Apr 11, 2018
Photoshop Generic backdrop gradient CSS3
View backdrop-gradient-css
.bg-gradient {
/* Old browsers */ /* FF3.6-15 */ /* Chrome10-25,Safari5.1-6 */ /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
background: -moz-linear-gradient(bottom, rgb(230, 230, 231, 1) 0%, rgba(255,255,255,0) 100%);
/* FF3.6-15 */
background: -webkit-linear-gradient(bottom, rgb(230, 230, 231, 1) 0%,rgba(255,255,255,0) 70%);
/* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to top, rgb(230, 230, 231, 1) 0%,rgba(255,255,255,0) 70%);
@gunjanpatel
gunjanpatel / php-syntax-error.sh
Created Mar 19, 2018
Find php syntax error on current directory
View php-syntax-error.sh
find . -type f -name "*.php" -print0 | xargs -0 -n 1 -P 8 php -l | grep -v 'No syntax errors'