Skip to content

Instantly share code, notes, and snippets.

View tallesairan's full-sized avatar
🏠
Working from home

Talles Airan tallesairan

🏠
Working from home
View GitHub Profile
@sokil
sokil / array_rand_weight.php
Last active July 20, 2016 04:40
Get random key from array due to weight in value.
<?php
function array_rand_weight(array $array)
{
reset($array);
$pointer = mt_rand(0, array_sum($array));
if(!$pointer) {
return key($array);
}
<?php
use CoverArtArchive\CoverArt;
use Guzzle\Http\Client;
use MusicBrainz\Filters\RecordingFilter;
use MusicBrainz\HttpAdapters\GuzzleHttpAdapter;
use MusicBrainz\MusicBrainz;
use phpFastCache\CacheManager;
use Ramsey\Uuid\Uuid;
@trueqap
trueqap / del_woo_products_with_ attachment.php
Created January 23, 2018 11:31
Delete WooCommerce products with images (attachment)
<?php
function delete_associated_media( $id ) {
$media = get_children( array(
'post_parent' => $id,
'post_type' => 'attachment'
) );
if( empty( $media ) ) {
return;
@viniciusmelocodes
viniciusmelocodes / selectpicker_uf_brasil.html
Last active November 30, 2018 12:43
selectpicker_uf_brasil
<select class="selectpicker" name="uf">
<option value="AC">Acre</option>
<option value="AL">Alagoas</option>
<option value="AP">Amapá</option>
<option value="AM">Amazonas</option>
<option value="BA">Bahia</option>
<option value="CE">Ceará</option>
<option value="DF">Distrito Federal</option>
<option value="ES">Espírito Santo</option>
<option value="GO">Goiás</option>
@umidjons
umidjons / restfull-htaccess
Created February 20, 2014 05:14
Allow GET,POST,PUT,DELETE RESTful requests in .htaccess
<Limit GET POST PUT DELETE>
order deny,allow
allow from all
</Limit>
@neatshell
neatshell / document.querySelectorCheatsheet
Last active March 4, 2020 20:23
document.querySelector* cheatsheet
// Get the canonical url of a page
document.querySelector("link[rel='canonical']").href;
document.querySelector("link[rel='canonical']").getAttribute("href");
@amboutwe
amboutwe / yoast_seo_meta_remove_dates.php
Last active October 5, 2020 08:39
Remove Date Meta Tags Output by Yoast SEO
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Remove Date Meta Tags Output by Yoast SEO
* Credit: Yoast development team
* Last Tested: Apr 09 2019 using Yoast SEO 10.1.3 on WordPress 5.1.1
* For Yoast SEO 14.0 or newer, please see https://yoast.com/help/date-appears-search-results/#h-managing-dates
*/
add_action('wpseo_dc_'.'DC.date.issued', '__return_false'); // Premium versions 5.2 or older
@fyrye
fyrye / font-awesome-mime-type-icons.php
Last active October 7, 2020 12:39 — forked from guedressel/font-awesome-mime-type-icons.php
Font Awesome File Icons: Mapping MIME Types to correct icon classes
<?php
/**
* Get font awesome file icon class for specific MIME Type
* @see https://gist.github.com/guedressel/0daa170c0fde65ce5551
* @param string|null $mime_type
* @return string
*/
function font_awesome_file_icon_class(?string $mime_type): string
{
@webarthur
webarthur / is_cnpj.js
Last active November 30, 2020 13:20
Valida CNPJ - função em JavaScript
function is_cnpj(c) {
var b = [6,5,4,3,2,9,8,7,6,5,4,3,2];
if((c = c.replace(/[^\d]/g,"")).length != 14)
return false;
if(/0{14}/.test(c))
return false;
for (var i = 0, n = 0; i < 12; n += c[i] * b[++i]);
<?php
/*
Plugin Name: woocommerce modal variationn
Plugin URI: #
Description: show modal window with product variations after clicking -add to cart-.
Version: 0.1
Author: Maks Buriy
Author URI: mailto:byymster@gmail.com
License: GPL2
*/