Skip to content

Instantly share code, notes, and snippets.

@NicolasPio
NicolasPio / smooth-fonts.scss
Last active August 29, 2015 13:56
Smooth Fonts
// Normal fonts
@mixin smooth-fonts {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
// Thin fonts
@mixin smooth-fonts-thin {
-webkit-text-stroke: 1px;
text-shadow: 1px 1px 1px black;
@NicolasPio
NicolasPio / .htaccess
Created June 6, 2014 15:40
Allow access to custom fonts
<FilesMatch "\.(ttf|otf|woff)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
@NicolasPio
NicolasPio / clear_cache_facebook.php
Created August 19, 2014 14:43
Clear the cache of the Facebook Open Graph
<?php
function clear_cache_facebook($post_id) {
$url = get_permalink($post_id);
$fb_graph_url = "https://graph.facebook.com/?id=". urlencode($url) ."&scrape=true";
$result = wp_remote_post($fb_graph_url);
}
add_filter('publish_post', 'clear_cache_facebook');
import flash.events.MouseEvent;
import flash.display.LoaderInfo;
// var link is instance name
link.buttonMode = true;
var paramList:Object = this.root.loaderInfo.parameters;
link.addEventListener(MouseEvent.CLICK, openURL);
function getCookieByName(name){
var cookies,
cookie,
endValue,
value;
cookies = document.cookie;
cookies = cookies.split('; ' + name + '=');
@NicolasPio
NicolasPio / gist:c00dd77c05d77073e5bc
Created November 4, 2014 14:24
Disable message update WordPress
add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );
@NicolasPio
NicolasPio / gist:79b6c9bb0fee7fb1c2fe
Created November 11, 2014 13:30
Social buttons asynchronous
<!-- Twitter -->
<script>
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.async=true;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');
</script>
<!-- Google Plus -->
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
<?php
/**
* Get first paragraph from a WordPress post. Use inside the Loop.
*
* @return string
*/
function get_first_paragraph(){
global $post;
$str = wpautop( get_the_content() );
#!/bin/bash
# Author: Nicolas Pio
# Description: Script para automotização de inicio de projetos na Mkt Virtual
#
# O que faz:
# - Baixa o WordPress em sua última versão
# - Instala o tema padrão da Mkt Virtual
# - Inicia o git
# - Configura o .gitignore
# - Instala as dependencias do tema
public function getSlug($slug)
{
$slug = preg_replace('~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', htmlentities($slug, ENT_QUOTES, 'UTF-8'));
$slug = preg_replace('~[^0-9a-z]+~i', '-', html_entity_decode($slug, ENT_QUOTES, 'UTF-8'));
$slug = strtolower( trim($slug, '-') );
return $slug;
}