Skip to content

Instantly share code, notes, and snippets.

View jqueryalmeida's full-sized avatar

Jquery Almeida jqueryalmeida

View GitHub Profile
@jqueryalmeida
jqueryalmeida / MultiExporter.jsx
Created December 22, 2016 16:04 — forked from TomByrne/MultiExporter.jsx
An Illustrator script for exporting layers and/or artboards into separate files (PNG8 / PNG24 / EPS / PDF / SVG / JPG / FXG).See http://www.tbyrne.org/export-illustrator-layers-to-svg-files
// MultiExporter.jsx
// Version 0.1
// Version 0.2 Adds PNG and EPS exports
// Version 0.3 Adds support for exporting at different resolutions
// Version 0.4 Adds support for SVG, changed EPS behaviour to minimise output filesize
// Version 0.5 Fixed cropping issues
// Version 0.6 Added inner padding mode to prevent circular bounds clipping
//
// Copyright 2013 Tom Byrne
// Comments or suggestions to tom@tbyrne.org
@jqueryalmeida
jqueryalmeida / deferred-ga.js
Created February 21, 2017 11:17 — forked from acdha/deferred-ga.js
Experiment deferring Google Analytics loading until after the DOM load event
var _gaq = _gaq || [];
_gaq.push(['_setAccount', YOUR_URCHIN_CODE]);
_gaq.push(['_trackPageview']);
_gaq.push(['_trackPageLoadTime']);
(function () {
function loadDeferredScripts() {
window.setTimeout(function () {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
@jqueryalmeida
jqueryalmeida / detect-private-browsing.js
Created April 5, 2017 21:59 — forked from cou929/detect-private-browsing.js
Detect private browsing mode (InPrivate Browsing or Incognito).
function retry(isDone, next) {
var current_trial = 0, max_retry = 50, interval = 10, is_timeout = false;
var id = window.setInterval(
function() {
if (isDone()) {
window.clearInterval(id);
next(is_timeout);
}
if (current_trial++ > max_retry) {
window.clearInterval(id);
@jqueryalmeida
jqueryalmeida / functions.php
Created May 8, 2017 14:38
Update json file after adding or updating a post in Wordpress
<?php
function fetchJSON( $post_id ) {
// Just for demo purpose, it's possible to fetch and pass data
$content = get_post_field('post_content', $post_id);
// open file
$open = curl_init();
curl_setopt($open, CURLOPT_URL, "https://mydomain.com/path/getContent.php?content=".$content);
curl_exec($open);
}
@jqueryalmeida
jqueryalmeida / functions.php
Created May 21, 2017 14:44 — forked from gregrickaby/functions.php
Add Google Fonts to Wordpress (the right way)
<?php
add_action( 'wp_enqueue_scripts', 'child_load_google_fonts' );
/**
* Enqueue Google Fonts using a function
*/
function child_load_google_fonts() {
// Setup font arguments
$query_args = array(
@jqueryalmeida
jqueryalmeida / co-authors-list.php
Created July 1, 2017 19:09 — forked from nciske/co-authors-list.php
List just co-authors with thumbnail
<?php
$args = array( 'post_type' => 'guest-author', 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' );
$guest_authors = get_posts( $args );
foreach( $guest_authors as $ga ){
echo '<div class="contributor">';
@jqueryalmeida
jqueryalmeida / comoSerChatoNoFacebook.js
Created October 20, 2017 13:04 — forked from callmeloureiro/comoSerChatoNoFacebook.js
Como fazer alguém te responder no facebook...
/*
Hoje iremos MUDAR a vida da pessoa que não te responde no Facebook...
Que tal enviar mensagens pra ela até obter uma resposta?!
Sensacional não acha?! Mas, somos devs, correto?! Então vamos automatizar esse paranauê!
Para utilizar:
- Abra o messenger.com;
- Selecione a conversa que você quer;
- Abra o console e cole o código que está no gist;
@jqueryalmeida
jqueryalmeida / ajax.php
Created October 26, 2017 20:51 — forked from sniperwolf/ajax.php
Super-Simple WordPress ajax post-popup with jQuery and Reveal plugin
<?php
/**
* Template Name: ajax
*/
?>
<?php
$post = get_post($_GET['id']);
?>
<?php if ($post) : ?>
<?php setup_postdata($post); ?>
<?php
/* WooCommerce emails for cancelled pending orders */
add_action('woocommerce_order_status_pending_to_cancelled', 'pending_cancelled_send_an_email_notification', 10, 2 );
function pending_cancelled_send_an_email_notification( $order_id, $order ) {
if ( version_compare( WC_VERSION, '3.0.8', '>=' ) ) {
// Getting all WC_emails objects
$email_notifications = WC()->mailer()->get_emails();
// Sending the email
$email_notifications['WC_Email_Cancelled_Order']->trigger( $order_id );
@jqueryalmeida
jqueryalmeida / _blank.js
Created December 29, 2017 15:45 — forked from CrocoDillon/_blank.js
Automatically open external links in new tab or window.
// vanilla JavaScript
var links = document.links;
for (var i = 0, linksLength = links.length; i < linksLength; i++) {
if (links[i].hostname != window.location.hostname) {
links[i].target = '_blank';
}
}
// or in jQuery