Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
<?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. | |
* |
Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
# | |
# 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/ |
// 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--) { |
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), |
People
![]() :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: |
<?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(); |
{ | |
"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"}, |
<?php | |
foreach( WC()->cart->get_cart_contents() as $cart_item_key => $cart_item ) { | |
var_dump($cart_item); | |
exit; | |
} | |
?> | |
array(13) { | |
["key"]=> | |
string(32) "c3804daac5b8859f0975d20c9fe3370e" |
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 |