Skip to content

Instantly share code, notes, and snippets.

View badah's full-sized avatar

Daniel Hernandes badah

View GitHub Profile
@jaredatch
jaredatch / functions.php
Last active October 12, 2024 21:26
WordPress Search Autocomplete using admin-ajax.php
<?php
/**
* Enqueue scripts and styles.
*
* @since 1.0.0
*/
function ja_global_enqueues() {
wp_enqueue_style(
'jquery-auto-complete',
@wpscholar
wpscholar / array-insert-before.php
Created November 7, 2015 13:08
Insert a value or key/value pair before a specific key in an array. If key doesn't exist, value is prepended to the beginning of the array.
<?php
/**
* Insert a value or key/value pair before a specific key in an array. If key doesn't exist, value is prepended
* to the beginning of the array.
*
* @param array $array
* @param string $key
* @param array $new
*
@wpscholar
wpscholar / array-insert-after.php
Created November 7, 2015 13:04
Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended to the end of the array.
<?php
/**
* Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended
* to the end of the array.
*
* @param array $array
* @param string $key
* @param array $new
*
@vishalbasnet23
vishalbasnet23 / Sublime-stuffs.txt
Created November 4, 2015 08:00
Install PHPCS with WordPress Coding Standard with Sublime Text 3
1. cmd+shift+p
2. Type phpcs and install it
3. Preferences > Package Settings > Php Code Sniffer > User settings
@joshuadavidnelson
joshuadavidnelson / has-gform.php
Created October 28, 2015 06:45
Check if the page has a gravity form
<?php
/**
* Check if the page has a gravity form.
*
* @since 1.0.0
*
* @param int $id Post or page id, default to false.
*
* @return boolean
*/
@paulirish
paulirish / what-forces-layout.md
Last active June 6, 2025 10:52
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@VictorHugoBatista
VictorHugoBatista / Demo_Mascara_Telefone.html
Last active June 17, 2017 19:59
Demo de máscara com expressão regular de telefone brasileiro que aceita número de 8 e 9 dígitos com DDD nos formatos (11) 2222-3333 e (11) 92222-3333. Fonte: http://elcio.com.br/ajax/mascara/
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Demo Máscara Telefone</title>
</head>
<body>
Telefone: <input onkeypress="mascaraTelefone(this)"/><br />
<script>
/*
@learncodeacademy
learncodeacademy / pubsub.js
Created July 29, 2015 02:54
Basic Javascript PubSub Pattern
//events - a super-basic Javascript (publish subscribe) pattern
var events = {
events: {},
on: function (eventName, fn) {
this.events[eventName] = this.events[eventName] || [];
this.events[eventName].push(fn);
},
off: function(eventName, fn) {
if (this.events[eventName]) {
@theodorosploumis
theodorosploumis / Install_Phpstorm.sh
Last active June 16, 2022 11:15
Update phpstorm on Ubuntu linux.
#!/bin/bash -e
# IMPORTANT. My phpstom installation exists on /opt/phpstorm.
# Early Access program: https://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Early+Access+Program
# For stable releases try: https://data.services.jetbrains.com/products/download?code=PS&platform=linux
if [ "$(whoami)" != "root" ]
then
echo "Sorry, you are not root."
exit 1
fi
@butlerblog
butlerblog / auto-login-from-reg-email.php
Last active November 14, 2024 11:08
WordPress auto login from native registration email
<?php
/*
This code snippet can be added to your functions.php file (without the <?php)
to add a query string to the login link emailed to the user upon registration
which when clicked will validate the user, log them in, and direct them to
the home page.
*/
/**
* This first function is hooked to the 'user_register' action which fires