Skip to content

Instantly share code, notes, and snippets.

View the94air's full-sized avatar
🐞
Looking for bugs. Pushing fixes.

Abdalla Arbab the94air

🐞
Looking for bugs. Pushing fixes.
View GitHub Profile
const events = ['click'];
function onClickOutside({ event, el, handler, middleware }) {
const isClickOutside =
event.target !== el
&& !el.contains(event.target);
if (!isClickOutside || !middleware(event, el)) {
return null;
}
@lostdesign
lostdesign / Dockerfile
Last active January 15, 2024 03:06
Run your Laravel project using Docker
FROM php:7.4-fpm
RUN apt-get update && apt-get install -qy --no-install-recommends \
curl \
openssl \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmagickwand-dev \
libmcrypt-dev \
libgmp-dev\
@techlab23
techlab23 / mutations.js
Created March 1, 2018 05:33
Vuex mutations with add, edit and delete entries
import Vue from 'vue'
import * as types from './mutation-types'
export default {
// Mutation to set entries in state
[types.SET_ENTRIES] (state, entries) {
state.entries = entries || {}
},
// Mutation to add entry in state
@voneff
voneff / .htaccess
Created February 28, 2018 13:07
WordPress: Disable PHP Execution in Certain WordPress Directories
# BEGIN Disable PHP Execution
#
# Source:
# http://www.wpbeginner.com/wp-tutorials/how-to-disable-php-execution-in-certain-wordpress-directories
#
<Files *.php>
deny from all
</Files>
@the94air
the94air / config.php
Last active January 30, 2017 14:22
Get a value from a multidimensional array using the dot syntax
<?php
class Helper
{
public static function get( $arr, $key, $default=null )
{
@list( $index, $key ) = explode( '.', $key, 2 );
if ( !isset( $arr[$index] ) ) return $default;
@jacurtis
jacurtis / _spacing-helpers.scss
Last active May 30, 2024 17:41
SASS Margin and Padding Helpers Loop. Generates .m-t-10 type helper classes.
/*
This .scss loop will create "margin helpers" and "padding helpers" for use in your web projects.
It will generate several classes such as:
.m-r-10 which gives margin-right 10 pixels.
.m-r-15 gives MARGIN to the RIGHT 15 pixels.
.m-t-15 gives MARGIN to the TOP 15 pixels and so on.
.p-b-5 gives PADDING to the BOTTOM of 5 pixels
.p-l-40 gives PADDING to the LEFT of 40 pixels
@jbanety
jbanety / build_pcntl.sh
Last active February 6, 2024 02:50
(Updated) Build PCNTL ext for MAMP PHP 7.4.2
#!/bin/bash
PHP_VERSION=7.4.2
# Command lines tools
xcode-select --install
# Install dependencies
brew install wget autoconf openssl lzlib curl imap-uw readline postgresql gettext libxslt libiconv bison pkg-config krb5 bzip2 openldap tidy-html5
# Dirs
@stracqan
stracqan / usb-credit-card-reader.js
Last active October 28, 2023 14:14
Very simple jQuery implementation that reads card data from a USB Magnetic Strip Credit Card Reader.
/**
*
* Simple jQuery Script to parse credit card data
* that was collected via a USB Magnetic Stripe
* Credit Card Reader.
*
* To get this to work, focus your cursor (either
* programmatically or via a click, it's your choice) on an input field #credit-card-number
* and then with the card reader plugged in, swipe
* the card and it will take over from there
@aarifhsn
aarifhsn / gist:d0535a720d13369010ce
Created December 25, 2015 08:57
Woocommerce get price in custom loop
<?php
global $woocommerce;
$currency = get_woocommerce_currency_symbol();
$price = get_post_meta( get_the_ID(), '_regular_price', true);
$sale = get_post_meta( get_the_ID(), '_sale_price', true);
?>
<?php if($sale) : ?>
<p class="product-price-tickr"><del><?php echo $currency; echo $price; ?></del> <?php echo $currency; echo $sale; ?></p>
<?php elseif($price) : ?>
@albertodebortoli
albertodebortoli / change_author_git_commit.md
Last active November 10, 2023 08:41
Change the author of a commit in Git

Using Interactive Rebase

git rebase -i -p <some HEAD before all of your bad commits>

Then mark all of your bad commits as "edit" in the rebase file, and when git asks you to amend each commit, do

git commit --amend --author "New Author Name <email@address.com>"

edit or just close the editor that opens, and then do