Skip to content

Instantly share code, notes, and snippets.

View michaelaguiar's full-sized avatar
🎯
Focusing

Michael Aguiar michaelaguiar

🎯
Focusing
View GitHub Profile
@michaelaguiar
michaelaguiar / CitiesArray.php
Created March 16, 2016 23:39 — forked from jonathonbyrdziak/CitiesArray.php
Cities Array :: An array of USA cities, as of April 2010
array(
'ALABAMA'=>
array('ABBEVILLE','ADAMSVILLE','ADDISON','AKRON','ALABASTER','ALBERTVILLE','ALEXANDER CITY','ALEXANDRIA','ALICEVILLE','ALLGOOD','ALTOONA','ANDALUSIA','ANDERSON','ANNISTON','ARAB','ARDMORE','ARGO','ARITON','ARLEY','ASHFORD','ASHLAND','ASHVILLE','ATHENS','ATMORE','ATTALLA','AUBURN','AUTAUGAVILLE','AVON','BABBIE','BAILEYTON','BANKS','BAY MINETTE','BAYOU LA BATRE','BEAR CREEK','BEATRICE','BEAVERTON','BELK','BENTON','BERRY','BESSEMER','BILLINGSLEY','BIRMINGHAM','BLACK','BLOUNTSVILLE','BLUE MOUNTAIN','BLUE RIDGE','BLUE SPRINGS','BOAZ','BOLIGEE','BON AIR','BRANCHVILLE','BRANTLEY','BRENT','BREWTON','BRIDGEPORT','BRIGHTON','BRILLIANT','BROOKSIDE','BROOKWOOD','BRUNDIDGE','BUTLER','BYNUM','CAHABA HEIGHTS','CALERA','CAMDEN','CAMP HILL','CARBON HILL','CARDIFF','CAROLINA','CARROLLTON','CASTLEBERRY','CEDAR BLUFF','CENTER POINT','CENTRE','CENTREVILLE','CHALKVILLE','CHATOM','CHELSEA','CHEROKEE','CHICKASAW','CHILDERSBURG','CITRONELLE','CLANTON','CLAY','CLAYHATCHEE','CLAYTON','CLEVELAND','CLIO','COALING',
@michaelaguiar
michaelaguiar / add-to-cart.js
Last active September 11, 2022 01:11
Woocommerce: Update Mini Cart on Ajax
// Update Mini Cart
$.post(
woocommerce_params.ajax_url,
{'action': 'mode_theme_update_mini_cart'},
function(response) {
$('#mode-mini-cart').html(response);
}
);
@michaelaguiar
michaelaguiar / wp-config.php
Created January 5, 2016 19:05
Wordpress Config to use PhpDotEnv package
<?php
require '../../vendor/autoload.php';
$dotenv = new Dotenv\Dotenv(__DIR__ . '/..');
$dotenv->load();
?>
@michaelaguiar
michaelaguiar / site.conf
Created September 16, 2015 19:12
NGINX Browser Caching
##
# Caching
##
# Expire rules for static content
location ~* \.(?:manifest|appcache|html?|xml|json)$ {
expires -1;
# access_log logs/static.log; # I don't usually include a static log
}
@michaelaguiar
michaelaguiar / clean.sh
Last active August 27, 2018 12:58
Clean up disk space - Ubuntu
# Show top 10 biggest subdirs in the current dir.
du -sk * | sort -nr | head -10
# Check if you have old kernels for deletion
ls -lh /boot
# Cleaning packages
sudo apt-get autoremove
sudo apt-get autoclean
@michaelaguiar
michaelaguiar / abbrNum.js
Created June 12, 2015 23:02
Abbreviate number. i.e. 250000 = 250K
function abbrNum(number, decPlaces) {
decPlaces = Math.pow(10,decPlaces);
var abbrev = ['K', 'M', 'B', 'T'];
for (var i = abbrev.length - 1; i >= 0; i--) {
var size = Math.pow(10,(i+1)*3);
if (size <= number) {
number = Math.round(number * decPlaces / size) / decPlaces;
@michaelaguiar
michaelaguiar / price.css
Created May 28, 2015 17:56
100% CSS Price Tag
.price {color:#fff; position:absolute; right:0; top:10px; height:48px; line-height:48px; padding:0 20px;}
.price:after {position:absolute; content:""; left:-12px; width:0px; height:0px; border-top:24px solid black; border-bottom:24px solid black; border-left:12px solid transparent;}
.price.red {background:#e1559a;}
.price.red:after {border-top-color:#e1559a; border-bottom-color:#e1559a;}
.price.blue {background:#329af2;}
.price.blue:after {border-top-color:#329af2; border-bottom-color:#329af2;}
.price.green {background:#a8d688;}
<?php
/**
* WooCommerce Extra Feature
* --------------------------
*
* Add custom fee to cart automatically
*
*/
function woo_add_cart_fee()
{
@michaelaguiar
michaelaguiar / shellshock.sh
Created September 25, 2014 17:12
Test for "ShellShock" bash vulnerability on Linux
env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
@michaelaguiar
michaelaguiar / coordinates.php
Created May 5, 2014 21:06
XLSX Parse and coordinate retrieval via Bing Maps API
<?php
require_once('simplexlsx.class.php');
$xlsx = new SimpleXLSX('test.xlsx', false, true);
$locations = array();
foreach ($xlsx->rows(3) as $row) {
if ($row[6]) {
$locations[] = array(
'address' => str_replace('.', '', str_replace('#', '', $row[6])),