Skip to content

Instantly share code, notes, and snippets.

View luiseduardobraschi's full-sized avatar
🤓
Updating knowledgebase...

Luis Braschi luiseduardobraschi

🤓
Updating knowledgebase...
View GitHub Profile
@luiseduardobraschi
luiseduardobraschi / .bashrc
Created May 26, 2017 08:52
My .bashrc setup.
source /opt/wp-completion.bash
export DEV=/var/www/html
export EDITOR=subl
export PS1="\[$(tput bold)\]\[\033[38;5;58m\]\u\[$(tput sgr0)\]\[\033[38;5;15m\]@\[$(tput sgr0)\]\[\033[38;5;58m\]\H\[$(tput sgr0)\]\[$(tput sgr0)\]\[\033[38;5;15m\] [\t] \w \\$\n> \[$(tput sgr0)\]"
# function to set terminal title
function set-title() {
if [[ -z "$ORIG" ]]; then
ORIG=$PS1
@luiseduardobraschi
luiseduardobraschi / ApplicationContext.cs
Created May 26, 2017 00:08
Friendship workflow using Entity Framework
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
namespace Test.Models {
public DbSet<Friendship> Friendships { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder) {
/* USER */
modelBuilder.Entity<User>().HasMany(u => u.Friends).WithMany();
@luiseduardobraschi
luiseduardobraschi / a2dissite.sh
Last active August 25, 2017 06:07
Apache 2's a2ensite and a2dissite for non-Deb based distros. Source (slightly modified): Apache virtual hosting in CentOS http://www.tecmint.com/apache-virtual-hosting-in-centos/
#!/bin/bash
avail=/etc/httpd/sites-enabled/$1.conf
enabled=/etc/httpd/sites-enabled
site=`ls /etc/httpd/sites-enabled/`
if [ "$#" != "1" ]; then
echo "Use script: a2dissite virtual_site"
echo -e "\nAvailable virtual hosts: \n$site"
exit 0
else
@gschoppe
gschoppe / WP_Persistent_Notices.php
Last active October 16, 2022 16:46 — forked from obenland/gist:5173811
Implements a standardized messaging system that allows admin notices to be passed across page redirects. usage: add_filter( 'wp_persistent_notices', function( $notices ) { $notices[] = array( 'type' => 'error', 'message' => "Houston, we have a problem!" ); return $notices; } );
<?php if( !defined( 'ABSPATH' ) ) { die(); } // Include in all php files, to prevent direct execution
/**
* Class Name : WP Persistent Notices
* Description : Implements a Standardized messaging system that allows admin messages to be passed across page redirects.
* Class URI : http://gschoppe.com/wordpress/pass-wordpress-admin-notices-across-page-redirects/
* Version : 1.0.0
* Author : Greg Schoppe
* Author URI : http://gschoppe.com
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
@luiseduardobraschi
luiseduardobraschi / list.html
Last active August 25, 2017 06:05
One-liner last-child style remover.
<style>
ul {
list-style:none;
}
li {
display: inline-block;
padding: 5px;
}
</style>
@iamphilrae
iamphilrae / phpMyAdmin Export Filename Template, Including Date and Time
Last active April 3, 2024 20:30
phpMyAdmin Export Filename Template, Including Date and Time
@DATABASE@__%Y-%m-%d_%H-%M-%S
@ahmadawais
ahmadawais / .zshrc
Created April 24, 2016 19:52
WP CLI Plugin & Theme Install/Activate Aliases for ZSH/BASH
# WP Plugin: Install & Acticate
# Usage: wpp plugin-slug
alias wpp="wp plugin install $* --activate"
# WP Theme: Install
# Usage: wpt plugin-slug
alias wpt="wp theme install $* --activate"
# WP Theme: Activate
# Usage: wpta plugin-slug
@luiseduardobraschi
luiseduardobraschi / changing-form-fields-after-user-log-in.php
Last active August 25, 2017 06:05
Since WordPress uses difrerent templates for both logged and not logged-in users, I ended up having to use some other hooks other than the default filter.
<?php
function alter_comment_form_fields($fields){
$commenter = wp_get_current_commenter();
$fields['author'] = '<p class="comment-form-input comment-form-author"><label for="author">' . __( 'This is a fancy label', 'your-text-domain' ) . '</label><input id="author" required name="author" type="text" placeholder="Seu nome" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" aria-required="true" /></p>';
return $fields;
}
@LeonardoCardoso
LeonardoCardoso / gitzip.sh
Last active October 9, 2023 22:38
Zip folder ignoring files listed on .gitignore
#...
function gitzip() {
git archive -o $@.zip HEAD
}
#... gitzip ZIPPED_FILE_NAME
@babeuloula
babeuloula / in_arrayi.php
Last active April 5, 2018 21:24 — forked from sepehr/in_arrayi.php
PHP: Case-insensitive in_array()
<?php
/**
* Case-insensitive in_array() wrapper.
*
* @param mixed $needle Value to seek.
* @param array $haystack Array to seek in.
* @param bool $strict If the third parameter strict is set to TRUE then the in_array() function will also check the types of the needle in the haystack.
*
* @return bool