Skip to content

Instantly share code, notes, and snippets.

@bytefade
bytefade / SQL_alternative_Distinct.sql
Last active August 29, 2015 14:08
Alternative distinc SQL
SELECT MIN(ID) as id, label as label_alt
FROM table
GROUP BY label
ORDER BY MIN(ID)
@bytefade
bytefade / gmapsRapido.php
Created October 23, 2014 12:29
Forma rápida e mediocre de pegar latitude longitude
<?php
$address = 'avenida+gustavo+paiva,maceio,alagoas,brasil';
$geocode = file_get_contents('http://maps.google.com/maps/api/geocode/json?address='.$address.'&sensor=false');
$output= json_decode($geocode);
@bytefade
bytefade / mask.php
Created October 21, 2014 12:46
Mascára em php
<?
function mask($val, $mask)
{
$maskared = '';
$k = 0;
for($i = 0; $i<=strlen($mask)-1; $i++)
{
if($mask[$i] == '#')
{
@bytefade
bytefade / current_user.php
Created October 17, 2014 13:27
current_user wordpress
<?php
$current_user = wp_get_current_user();
/**
* @example Safe usage: $current_user = wp_get_current_user();
* if ( !($current_user instanceof WP_User) )
* return;
*/
// echo 'Username: ' . $current_user->user_login . '<br />';
// echo 'User email: ' . $current_user->user_email . '<br />';
@bytefade
bytefade / availWidth.js
Created October 3, 2014 19:30
availWidth and availHeight
function getWidth()
{
xWidth = null;
if(window.screen != null)
xWidth = window.screen.availWidth;
if(window.innerWidth != null)
xWidth = window.innerWidth;
if(document.body != null)
@bytefade
bytefade / shadowGoogle.css
Created September 25, 2014 16:47
Shadow google
#docs-homescreen-add {
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
border: none;
bottom: 24px;
-webkit-box-shadow: 0px 2px 10px rgba(0,0,0,.3),0px 0px 1px rgba(0,0,0,.1),inset 0px 1px 0px rgba(255,255,255,.25),inset 0px -1px 0px rgba(0,0,0,.15);
-moz-box-shadow: 0px 2px 10px rgba(0,0,0,.3),0px 0px 1px rgba(0,0,0,.1),inset 0px 1px 0px rgba(255,255,255,.25),inset 0px -1px 0px rgba(0,0,0,.15);
box-shadow: 0px 2px 10px rgba(0,0,0,.3),0px 0px 1px rgba(0,0,0,.1),inset 0px 1px 0px rgba(255,255,255,.25),inset 0px -1px 0px rgba(0,0,0,.15);
cursor: pointer;
@bytefade
bytefade / call.js
Created September 9, 2014 17:08
Calltest
//Formulário de adesão validar
$('#formulario_adesao').validator().bind('onFail', function(e,errors){
var primeiroImput = false;
if ('submit' == e.originalEvent.type) {
$.each(errors, function() {
var input = this.input;
switch (input.attr('name')){
case 'idplano':
$('#div-valor_titular').css('display', 'block'); break;
case 'concodar_plano': $('#div-concodar_plano').css('display', 'block');
@bytefade
bytefade / urlThumbnail.php
Created September 1, 2014 12:21
Retornar url thumbnail wordpress
<?php
$thumb_id = get_post_thumbnail_id();
$thumb_url = wp_get_attachment_image_src($thumb_id,'thumbnail', true);
@bytefade
bytefade / gulp.js
Last active August 29, 2015 14:05
Gulp
// -- include gulp
var gulp = require('gulp');
// -- include plug-ins
var jshint = require('gulp-jshint');
var changed = require('gulp-changed');
var imagemin = require('gulp-imagemin');
var concat = require('gulp-concat');
var stripDebug = require('gulp-strip-debug');
var uglify = require('gulp-uglify');
@bytefade
bytefade / git_comandos_bash.md
Last active November 12, 2015 00:00
Comandos que mais uso no GIT

Remover arquivos deletados, faz um filtro:

  • git diff --name-only --diff-filter=D -z | xargs -0 git rm --cached

Remover, parar de versionar arquivos individuais:

  • git rm nameFileHere --cached

Exportar log de commit para csv: