Skip to content

Instantly share code, notes, and snippets.

View pedrorvidal's full-sized avatar

Pedro Vidal pedrorvidal

  • Porto Alegre, Brazil.
  • 01:19 (UTC -03:00)
View GitHub Profile
@pedrorvidal
pedrorvidal / open-files-in-tabs-under-unix-vim.sh
Last active August 29, 2015 13:58
Abre arquivos no Vim SEMPRE em abas.
#In the gvim.desktop desktop file (/usr/share/applications/ for most GNU/Linux systems) look for the "Exec" line. It will probably be like this:
#Look for this line
Exec=gvim -f %F
#Change the Exec line to:
Exec=gvim -p --remote-tab-silent %F
#IMPORTANT
#You may also need to change the StartupNotify value to "false" if it is currently set "true", or your Vim may not respond properly when the file is already open in a tab.
@pedrorvidal
pedrorvidal / grep.sh
Created April 25, 2014 17:15
Grep for recursive search inside folder
#search only inside php files. For ALL files, remove the --include option
grep -nHoR --include=*.php 'searched_string' *
<?php
#source http://blog.escapecreative.com/wordpress-display-all-images-attached-to-post-page/
$images =& get_children( array (
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image'
));
if ( empty($images) ) {
// no attachments here
<?php
#source http://bavotasan.com/2011/a-better-way-to-remove-images-from-a-wordpress-post/
function remove_images( $content ) {
$postOutput = preg_replace('/<img[^>]+./','', $content);
return $postOutput;
}
add_filter( 'the_content', 'remove_images', 100 );
?>
<?php remove_filter( 'the_content', 'remove_images', 100 ); ?>
#GIT#
git checkout -b branch-name master
git status
git add <some-file>
git commit
git push -u origin branch-name
@pedrorvidal
pedrorvidal / wordpress-post-thumbnail-or-first-image-or-default.php
Last active August 29, 2015 14:26 — forked from brajeshwar/wordpress-post-thumbnail-or-first-image-or-default.php
Wordpress - Get the Image from Post Thumbnail or the First Image of a post or else use a default Image.
/*
* Display Image from the_post_thumbnail or the first image of a post else display a default Image
* Chose the size from "thumbnail", "medium", "large", "full" or your own defined size using filters.
* USAGE: <?php echo my_image_display(); ?>
*/
function my_image_display($size = 'full') {
if (has_post_thumbnail()) {
$image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id, $size);
@pedrorvidal
pedrorvidal / untrack.git
Created September 14, 2015 14:17
Git untrack file
// stop tracking file
git update-index --assume-unchanged <filename>
@pedrorvidal
pedrorvidal / EntityRepo.php
Last active September 22, 2015 21:37
Caso Symfony2 Not working consulta a banco
/**
*
* @param $publicado
* @return array
*/
public function getBackgroundHomeFunc($publicado = 1)
{
$dql = "SELECT e FROM {$this->entity} e WHERE 1 = 1";
$parametros = array();