Skip to content

Instantly share code, notes, and snippets.

View marcosfreitas's full-sized avatar
🔥
Looking forward

Marcos Freitas marcosfreitas

🔥
Looking forward
View GitHub Profile
function gpShare(url, title, descr, image, winWidth, winHeight) {
var winTop = (screen.height / 2) - (winHeight / 2);
var winLeft = (screen.width / 2) - (winWidth / 2);
window.open('https://plus.google.com/share?url=' + url + '&p[summary]=' + descr + '&p[url]=' + url + '&p[images][0]=' + image, 'sharer', 'top=' + winTop + ',left=' + winLeft + ',toolbar=0,status=0,width=' + winWidth + ',height=' + winHeight);
}
function fbShare(url, title, descr, image, winWidth, winHeight) {
var winTop = (screen.height / 2) - (winHeight / 2);
var winLeft = (screen.width / 2) - (winWidth / 2);
@marcosfreitas
marcosfreitas / index.html
Last active January 29, 2016 17:17
[UPDATED] Responsive Images, using img element. -- The First Image are loading wrong.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Responsive Image</title>
</head>
<body>
<div class="videos">
@marcosfreitas
marcosfreitas / json-api.php
Created December 4, 2015 17:23
Utilizando o JSON PARSER (https://github.com/kuma-giyomu/JSONParser) para retornar parte de um grande arquivo JSON.
<?php
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
//header('Content-Type: application/json; charset=utf-8');
header('Content-Type: text/html; charset=utf-8');
ini_set("memory_limit","128M");
set_time_limit(120);
ob_start();
<?php
(..)
$attached_media = get_attached_media( $this->supported_types, $this->post_id );
foreach ($attached_media as $key => $value) {
$attachment_url = $attached_media[$key]->guid;
}
(...)
var arr_links = new Array();
function iFrame (tbody, i){
arr_links.push(tbody.find('iframe').find('flideo').find('video'));
console.info(arr_links[i]);
};
/* PARTE 0 */
var sNew = document.createElement("script");
sNew.async = true;
sNew.src = "https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js";
@marcosfreitas
marcosfreitas / woo-query.php
Last active July 15, 2016 16:25
Query de busca com relevância para as avaliações dos usuários e também para quando o conteúdo pesquisado está presente nos títulos, categorias e conteúdos.
<?php
/*
Seleciona todos os campos da tabela wp_posts (p.*) e todos os resultados vindos do LEFT OUTER JOIN (R.*).
E também mostra a QUANTIDADE de avaliações e a MEDIA vindas dos outros LEFT OUTER JOIN (X e Y).
O Primeiro LEFT OUTER JOIN (R) trata a busca pelas categorias de cada produto,
os outros JOINS trazem a soma das avaliações e a quantidade de votos, a partir daí a MÉDIA é formada dividindo as soma pela quantidade de votos.
*/
SELECT p.*, R.*, X.TAXA AS TAXA, Y.QUANTIDADE AS QUANTIDADE,
@marcosfreitas
marcosfreitas / woo.text
Last active August 29, 2015 14:26
Wordpress Custom Query - Woocommerce Search Order By Rating
'
1º LEFT OUTER JOIN somente a soma das avaliacoes
2º LEFT OUTER JOIN somente a quantidade das avaliacoes
resulta na média
POSTS, COMENTARIOS, METADADOS_COMENTARIOS
inner join nao vai trazer os posts sem comentarios ou comentarios sem classificacao rating
left outer join vai trazer os posts, comentarios coincidentes no inner (na relacao descrita no ON) e tambem os posts sem comentarios, comentario sem rating
select * from POSTS
select * from COMENTARIOS as c
left outer join METADADOS_COMENTARIOS as mc
@marcosfreitas
marcosfreitas / sui-fixed-layout.html
Last active July 31, 2020 12:26
Fixed Layout with Semantic UI
<!DOCTYPE HTML>
<html>
<head>
<!-- add the semantic assets -->
</head>
<body>
<style>
/**
* Semantic UI don't have a fixed grid system, the solution to build fixed layouts is use a grid inside a fixed container.
*/
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Registration.aspx.cs" Inherits="ITI_Intake_34.Day_5.Registration" %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="description" content="A form displays a set of related user input fields in a structured way" />
<meta name="keywords" content="html5, ui, library, framework, javascript" />
<title>Semantic Ui</title>
@marcosfreitas
marcosfreitas / colors.php
Last active August 29, 2015 14:19
JSON what will be returned to search of Semantic UI - JSON que será retornado para a pesquisa (search) do Semantic UI.
<?php
header('Content-type: application/json; charset=utf-8');
$colors = '{"results" :[
{
"title":"red",
"description":"dark red like blood"
},
{
"title":"green",