Skip to content

Instantly share code, notes, and snippets.

View silasrm's full-sized avatar

Silas Ribas Martins silasrm

View GitHub Profile
@silasrm
silasrm / wp-query-ref.php
Created September 29, 2015 21:48 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
@silasrm
silasrm / jquery-textarea-form-submit-cmd-enter.js
Last active September 18, 2015 04:41 — forked from alexkingorg/jquery-textarea-form-submit-cmd-enter.js
Submit a form on Command+Enter when in a textarea field.
jQuery(function($) {
// add a handler for form submit (makes an AJAX call)
$(document).on('submit', 'form.my-class', myFormSubmitHandler);
// submit form on command + enter if in a textarea
$(document).on('keydown', 'body', function(e) {
if (!(e.keyCode == 13 && e.metaKey)) return;
var $target = $(e.target);
if ($target.is('textarea')) {
@silasrm
silasrm / redis_
Last active August 29, 2015 14:27 — forked from colinmollenhour/redis_
Munin plugin for Redis with added options
#!/usr/bin/perl -w
#
## Copyright (C) 2011 Colin Mollenhour <http://colin.mollenhour.com/>
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License
## as published by the Free Software Foundation; version 2 dated June,
## 1991.
##
@silasrm
silasrm / CpfCnpj.php
Last active August 29, 2015 14:24 — forked from afranioce/CpfCnpj.php
<?php
namespace Obras\Bundle\CadastroBundle\Validator\Constraints;
use Symfony\Component\Validator\Constraint;
/**
* @Annotation
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
*
@silasrm
silasrm / Form.php
Last active August 29, 2015 14:24 — forked from jgornick/Form.php
<?php
// ...
$this->addElementPrefixPath('My_Validate', 'My/Validate/', 'validate');
$this->addElement('text', 'start_time', array(
'label' => 'Start Time (GMT)',
'class' => 'datetime',
'required' => true,
'validators' => array(
/*
verifica_cpf_cnpj
Verifica se é CPF ou CNPJ
@see http://www.tutsup.com/
*/
function verifica_cpf_cnpj ( valor ) {
// Garante que o valor é uma string
@silasrm
silasrm / cap-first.sql
Created November 26, 2014 22:38
Função para MySQL para mudar a caixa do texto para Título (CamelCase) Ref: http://joezack.com/2008/10/20/mysql-capitalize-function/
DELIMITER $$
CREATE FUNCTION CAP_FIRST (input VARCHAR(255))
RETURNS VARCHAR(255)
DETERMINISTIC
BEGIN
DECLARE len INT;
DECLARE i INT;
@silasrm
silasrm / Meu\AppBundle\EventListener\UploadListener.php
Last active November 9, 2017 14:52
Listener de upload para OneupUploaderBundle que integra com Plupload.
<?php
namespace Meu\AppBundle\EventListener;
use Oneup\UploaderBundle\Event\PostPersistEvent;
class UploadListener
{
protected $service;
@silasrm
silasrm / truncate.filter.js
Last active August 29, 2015 14:04
Filtro que trunca uma string e adiciona uma string no final (por default sendo '...')
// ########################################################################### //
// ########################################################################### //
// - Truncate - //
// ########################################################################### //
// ########################################################################### //
/**
* Truncate Filter
* @Param text
* @Param length, default is 10
* @Param end, default is "..."
@silasrm
silasrm / html2plaintext.filter.js
Last active August 29, 2015 14:04
Filtra códigos html e deixa somente texto
// ########################################################################### //
// ########################################################################### //
// - Html2Plaintext - //
// ########################################################################### //
// ########################################################################### //
define(
[
'app',
],
function(app) {