Skip to content

Instantly share code, notes, and snippets.

View pietropr's full-sized avatar
🏆
Living

Pietro Pinton Rosa pietropr

🏆
Living
  • Botucatu - São Paulo
View GitHub Profile
@lucianomlima
lucianomlima / adb_connect.sh
Created June 5, 2019 17:57
Connect to Android devices with ADB through wi-fi
function adb_connect {
# PORT used to connect. Default: 5555
PORT=${1:-5555}
# IP address from current device connected
IP_ADDRESS=`adb shell ip route | awk '{print $9}'`
echo "ADB connect to $IP_ADDRESS on port $PORT"
# Change connection from usb to tcpip using $PORT
@RadGH
RadGH / wc-cart-item-var_dump.php
Last active August 6, 2021 19:37
WooCommerce: $cart_item var_dump
<?php
foreach( WC()->cart->get_cart_contents() as $cart_item_key => $cart_item ) {
var_dump($cart_item);
exit;
}
?>
array(13) {
["key"]=>
string(32) "c3804daac5b8859f0975d20c9fe3370e"
{
"UF": [
{"nome": "Acre", "sigla": "AC"},
{"nome": "Alagoas", "sigla": "AL"},
{"nome": "Amapá", "sigla": "AP"},
{"nome": "Amazonas", "sigla": "AM"},
{"nome": "Bahia", "sigla": "BA"},
{"nome": "Ceará", "sigla": "CE"},
{"nome": "Distrito Federal", "sigla": "DF"},
{"nome": "Espírito Santo", "sigla": "ES"},
@ianhampton
ianhampton / contact-form-7-dynamic-attachment.php
Last active November 7, 2024 22:12
Dynamically add file attachments to Contact Form 7 emails from a custom field
<?php
/* Dynamically add file attachments to Contact Form 7 emails from a Wordpress custom field.
* Custom field is 'case-pdf' in the example.
*/
add_action('wpcf7_before_send_mail', 'wpcf7_add_attachment');
function wpcf7_add_attachment($contact_form) {
global $_POST;
$submission = WPCF7_Submission::get_instance();
@rxaviers
rxaviers / gist:7360908
Last active November 15, 2024 16:55
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@rafaellyra
rafaellyra / calculatedistance.js
Created March 17, 2013 09:11
Calcula a distancia em raio entre duas coordenadas de latitude/longitude.
function CalcRadiusDistance(lat1, lon1, lat2, lon2) {
var RADIUSMILES = 3961,
RADIUSKILOMETERS = 6373,
latR1 = this.deg2rad(lat1),
lonR1 = this.deg2rad(lon1),
latR2 = this.deg2rad(lat2),
lonR2 = this.deg2rad(lon2),
latDifference = latR2 - latR1,
lonDifference = lonR2 - lonR1,
a = Math.pow(Math.sin(latDifference / 2), 2) + Math.cos(latR1) * Math.cos(latR2) * Math.pow(Math.sin(lonDifference / 2), 2),
@DiegoSalazar
DiegoSalazar / validate_credit_card.js
Last active October 22, 2024 21:47
Luhn algorithm in Javascript. Check valid credit card numbers
// Takes a credit card string value and returns true on valid number
function valid_credit_card(value) {
// Accept only digits, dashes or spaces
if (/[^0-9-\s]+/.test(value)) return false;
// The Luhn Algorithm. It's so pretty.
let nCheck = 0, bEven = false;
value = value.replace(/\D/g, "");
for (var n = value.length - 1; n >= 0; n--) {
@Zodiac1978
Zodiac1978 / .htaccess
Last active August 15, 2024 18:00
Make your Website faster - a safe htaccess way
#
# Sources:
# http://stackoverflow.com/questions/7704624/how-can-i-use-gzip-compression-for-css-and-js-files-on-my-websites
# http://codex.wordpress.org/Output_Compression
# http://www.perun.net/2009/06/06/wordpress-websites-beschleuinigen-4-ein-zwischenergebnis/#comment-61086
# http://www.smashingmagazine.com/smashing-book-1/performance-optimization-for-websites-part-2-of-2/
# http://gtmetrix.com/configure-entity-tags-etags.html
# http://de.slideshare.net/walterebert/die-htaccessrichtignutzenwchh2014
# http://de.slideshare.net/walterebert/mehr-performance-fr-wordpress
# https://andreashecht-blog.de/4183/
@ziadoz
ziadoz / awesome-php.md
Last active July 13, 2024 05:29
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.
@jakebellacera
jakebellacera / ICS.php
Last active October 11, 2024 10:58
A convenient script to generate iCalendar (.ics) files on the fly in PHP.
<?php
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*