Skip to content

Instantly share code, notes, and snippets.

View andrezrv's full-sized avatar

Andrés Villarreal andrezrv

View GitHub Profile
@andrezrv
andrezrv / wordpress-admin-notice.php
Last active December 25, 2015 13:29
How to display a notice in the admin section of WordPress.
<?php
/**
* Displays a notice in the admin section under some condition.
*
* @author andrezrv
*/
function my_admin_notice() {
global $current_screen;
@andrezrv
andrezrv / MyBuildTestData.groovy
Last active December 24, 2015 00:39
How to test with Spock using Build Test Data Plugin for Grails. Spock Docs: http://docs.spockframework.org/ Build Test Data Docs & Repo: https://github.com/tednaleid/build-test-data
package myapp.downloads
import grails.test.mixin.TestFor
import spock.lang.Specification
import grails.buildtestdata.mixin.Build
/**
* See the API for {@link grails.test.mixin.support.GrailsUnitTestMixin} for usage instructions
*/
@TestFor( Download )
@andrezrv
andrezrv / MyObject.groovy
Last active December 23, 2015 20:29
How to test exceptions in Grails using Spock.
package myapp.mypackage
/**
* Just an example of a domain class.
* @author andrezrv
*/
class MyObject {
String name
@andrezrv
andrezrv / config.rb
Last active December 21, 2015 07:39
Custom configuration file for WP-Stack, loading a new set of tasks from db-tasks.rb and shared-tasks.rb.
# Customize according to your needed configuration
set :application, "Application Name"
set :repository, "git@github.com:user/repo.git"
set :db_repository, 'git@github.com:user/repo-db.git'
set :scm, :git
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
# This assumes you're using Git. Needed to run tasks in db-tasks.rb
set :git_user_name, "user"
@andrezrv
andrezrv / move-wordpress.sql
Created June 24, 2013 21:44
How to Move WordPress Blog to New Domain or Location
SELECT @old_domain := 'http://www.old-domain.com' , @new_domain := 'http://www.new-domain.com';
UPDATE wp_options SET option_value = replace(option_value, @old_domain, @new_domain) WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, @old_domain, @new_domain);
UPDATE wp_posts SET post_content = replace(post_content, @old_domain, @new_domain);
@andrezrv
andrezrv / sql-variables.txt
Created June 24, 2013 17:00
How to use MySQL variables
mysql> SELECT @min_price:=MIN(price),@max_price:=MAX(price) FROM shop;
mysql> SELECT * FROM shop WHERE price=@min_price OR price=@max_price;
+---------+--------+-------+
| article | dealer | price |
+---------+--------+-------+
| 0003 | D | 1.25 |
| 0004 | D | 19.95 |
+---------+--------+-------+