Skip to content

Instantly share code, notes, and snippets.

@LeCoupa
LeCoupa / bash-cheatsheet.sh
Last active July 16, 2024 17:25
Bash CheatSheet for UNIX Systems --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04
@EvanHerman
EvanHerman / check-if-element-in-viewport-on-scroll.js
Last active May 31, 2023 13:23
Check when an element comes into view (jQuery)
function isOnScreen(elem) {
// if the element doesn't exist, abort
if( elem.length == 0 ) {
return;
}
var $window = jQuery(window)
var viewport_top = $window.scrollTop()
var viewport_height = $window.height()
var viewport_bottom = viewport_top + viewport_height
var $elem = jQuery(elem)
@jaw-sh
jaw-sh / gist:2dd0eb3be4c0845813e4
Last active October 17, 2020 10:50
NGINX catch-all for redirecting www and http to non-www https
# Redirect http:// to https://
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 301 https://$host$request_uri;
}
# Redirect https://www to https://
@jaw-sh
jaw-sh / cloudflare.sh
Last active October 17, 2020 08:29
Bash file to pull Cloudflare IPs from their API endpoints. Can be used in CRON jobs.
#!/bin/bash
# Author: Joshua Moon <josh@jaw.sh>
# Date: 14-May-2016
# Purpose: Creates an up-to-date Cloudflare nginx config file.
# License: MIT
################################################################################
# INSTRUCTIONS
#!/bin/bash
iatest=$(expr index "$-" i)
#######################################################
# SOURCED ALIAS'S AND SCRIPTS BY zachbrowne.me
#######################################################
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
@Astargh
Astargh / function.php
Created February 22, 2017 22:41
Quick view woocommerce
wp_enqueue_script( 'my-ajax-request', get_template_directory_uri() . '/js/main.js' );
wp_localize_script( 'my-ajax-request', 'myajax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
add_action('wp_ajax_woo_quickview', 'woo_quickview');
add_action('wp_ajax_nopriv_woo_quickview', 'woo_quickview');
function woo_quickview() {
global $post, $product, $woocommerce;
@MSerj
MSerj / multiple_swiper.js
Last active July 27, 2022 16:07
Multiple Instances of Swiper on Same page
if ($('.swiper-container').length > 0) { //some-slider-wrap-in
let swiperInstances = [];
$(".swiper-container").each(function(index, element){ //some-slider-wrap-in
const $this = $(this);
$this.addClass("instance-" + index); //instance need to be unique (ex: some-slider)
$this.parent().find(".swiper-pagination").addClass("pagination-" + index);
$this.parent().find(".swiper-button-prev").addClass("prev-" + index); //prev must be unique (ex: some-slider-prev)
$this.parent().find(".swiper-button-next").addClass("next-" + index); //next must be unique (ex: some-slider-next)
swiperInstances[index] = new Swiper(".instance-" + index, { //instance need to be unique (ex: some-slider)
// your settings ...
@jeromecoupe
jeromecoupe / webstoemp-gulpfile.js
Last active January 21, 2024 16:28
Gulp 4 sample gulpfile.js. For a full explanation, have a look at https://www.webstoemp.com/blog/switching-to-gulp4/
"use strict";
// Load plugins
const autoprefixer = require("autoprefixer");
const browsersync = require("browser-sync").create();
const cp = require("child_process");
const cssnano = require("cssnano");
const del = require("del");
const eslint = require("gulp-eslint");
const gulp = require("gulp");
@bradtraversy
bradtraversy / docker-help.md
Last active July 9, 2024 10:18
Docker Commands, Help & Tips

Docker Commands, Help & Tips

Show commands & management commands

$ docker

Docker version info

@passcod
passcod / __why-and-how-to-use.md
Last active March 22, 2023 13:33
Bootstrap 4 mixins for spacing utilities without classes

Why?

This:

.action {
  @extend .ml-3;
}