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 / iOS.css
Created September 27, 2012 17:54
iOS Media Queries
/* Non-Retina */
@media screen and (-webkit-max-device-pixel-ratio: 1) {
}
/* Retina */
@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (min--moz-device-pixel-ratio: 1.5), only screen and (min-device-pixel-ratio: 1.5) {
}
@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 / rename.swift
Created June 7, 2016 00:08
Rename a file in Swift
// Create a FileManager instance
let fileManager = NSFileManager.defaultManager()
// Rename 'hello.swift' as 'goodbye.swift'
do {
try fileManager.moveItemAtPath("hello.swift", toPath: "goodbye.swift")
} catch let error as NSError {
print("Ooops! Something went wrong: \(error)")
}
@michaelaguiar
michaelaguiar / GoogleScrape.class.php
Created September 11, 2012 22:04
Google Result Scraper
<?php
require_once('simple_html_dom.php');
class Google_Scrape
{
private $html = null;
private $query = null;
private $results = 0;
public function __construct($query='sample', $results=20)
@michaelaguiar
michaelaguiar / README
Created March 6, 2012 21:29
JS - Calculate BMI
BMI Calculator
@michaelaguiar
michaelaguiar / pgsql_error.php
Created February 7, 2012 18:15
PostgreSQL Error Codes => Descriptions
<?php
/**
* @author: Michael Aguiar <mike@aliasproject.com>
* @desc: An array of PostgreSQL Error Codes' => Descriptions
*/
$PGError = array(
'00000' => 'SUCCESSFUL COMPLETION',
'01000' => 'WARNING',
'0100C' => 'DYNAMIC RESULT SETS RETURNED',
@michaelaguiar
michaelaguiar / autocomplete.js
Created May 18, 2020 15:29
Google Maps Address Autocomplete
function initAutoComplete() {
var input = document.getElementById("grid-address");
var autocomplete = new google.maps.places.Autocomplete(input);
autocomplete.addListener("place_changed", function () {
let place = autocomplete.getPlace();
let address = "";
if (place.address_components) {
address = [
@michaelaguiar
michaelaguiar / email.php
Last active July 28, 2020 20:54
PHP - Send Email
<?php
// Configuration
$myEmail = 'YOUR EMAIL HERE';
$error = '';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
@michaelaguiar
michaelaguiar / private.php
Created October 22, 2019 23:15
Laravel validate before downloading private file
<?php
public function downloadFile(Request $request)
{
// !VALIDATE USER HAS ACCESS
// Get response and clean before return
$response = Storage::download(FILE_PATH_HERE);
ob_end_clean();
@michaelaguiar
michaelaguiar / my.cnf
Created August 16, 2019 17:16
Decrease memory consumption of MySQL 5.7
performance_schema = 0
show_compatibility_56 = 1