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
<?php
namespace App\Controllers\Site\Ads;
use Silex\Application;
use Symfony\Component\HttpFoundation\Request;
use Silex\Api\ControllerProviderInterface;
class AdsControllerProvider implements ControllerProviderInterface {
@marcosfreitas
marcosfreitas / get_date.php
Last active June 2, 2017 18:49
Abstraction to get date e anyone formats
<?php
/**
* Check if a string is a valid based on $formats['input'], then format an output based on $formats['output']
* @author Marcos Freitas
* @param string $value The string of the date
* @param array $formats The given input and wanted output formats of the date.
* @return string|boolean
*/
public static function getDate($value, $formats){
@marcosfreitas
marcosfreitas / mf-pagination.php
Created January 12, 2017 00:40
Create a custom pagination based on total of pages received
<style>
.mf-pagination {
display: block;
list-style: none;
margin: 2em 0 0 0;
width: 100%;
padding: 1em;
text-align: right;
font-size: 1.2em;
}
@marcosfreitas
marcosfreitas / .htaccess
Created October 29, 2016 22:04
rewrite folder "web/" inside silex
# Project'a Structure
# localhost/projects/myProject/
# -- .htacess
# | -- RewriteEngine On
# | -- RewriteBase /projects/myProject/
# | -- DirectoryIndex web/index.php
# -- src/
# ----- App/
# -- web/
@marcosfreitas
marcosfreitas / facebook-delete-all-group-members.js
Last active September 22, 2016 10:10 — forked from babrath/fb_delete_allgroupmembers.js
This code works! Facebook disabled the native console brownser, but if you install the "Firebug" extension and run this script, it will work for you! This script does not delete the group, just remove all the other members and then terminates execution.
// first go to https://www.facebook.com/groups/XXXX/members/
// then paste this in the javascript console
// IF YOU WANT NOT TO INSTALL THE FIREBUG EXTENSION, YOU CAN ACTIVATE THE USE OF THE CONSOLE HERE: https://www.facebook.com/selfxss
deleteAll = [];
deleteAll.elms = [];
deleteAll.canClick = function (el) {
return (typeof el != 'undefined') && (typeof el.click != 'undefined');
}
@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,
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">
<?php
header('Content-Type: application/json; charset=utf-8');
error_reporting(true);
try{
/**
<?php
header('Content-Type: text/html; charset=ISO-8859-1');
//header('Content-Type: application/json; charset=utf-8');
ini_set('display_errors', 1);
error_reporting(E_ALL);
ob_clean(); //apaga o buffer de saída
/* Definições */
/*=====================================================================