Skip to content

Instantly share code, notes, and snippets.

View tcelestino's full-sized avatar
🙃

Tiago Celestino tcelestino

🙃
View GitHub Profile
<?php
ob_start();
if(!function_exists("do_action")) :
header('content-type: text/xml');
include_once('../../../../wp-config.php');
endif;
$xml = array();
$xml[] = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
$xml[] = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";
$xml[] = "<lista>";
@tcelestino
tcelestino / handlebras-helpers.js
Last active December 31, 2015 23:48
Handlebars Helpers
// console
Handlebars.registerHelper("debug", function(optionalValue) {
console.log("Current Context");
console.log("====================");
console.log(this);
if (optionalValue) {
console.log("Value");
console.log("====================");
console.log(optionalValue);
@tcelestino
tcelestino / blank_window.js
Created November 28, 2013 17:30
open all links in page with target="_blank" in a new window
window.onload = function() {
var links = document.getElementsByTagName('a'), len = links.length;
for(var i = 0; i < len; i++) {
links[i].addEventListener('click', function(event) {
if (this.target === '_blank') {
window.open(this.url, '_blank');
}
@tcelestino
tcelestino / mixins.scss
Last active December 28, 2015 05:09
my custom mixins SASS
// return width - padding
@function calc-width($width, $padding) {
@return $width - $padding
}
// return height - padding
@function calc-height($height, $padding) {
@return $height - $padding
}
@tcelestino
tcelestino / .bash_profile
Last active August 22, 2016 23:02
my bashrc profile
# ENVIRONMENT
#export JAVA_HOME=~/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home
export ANT_HOME=/Users/$USER/Development/apache-ant-1.8.2
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
export JBOSS_HOME=/Users/$USER/Development/jboss-5.1.0.GA
export JETTY_HOME=/Users/$USER/Development/jetty-6.1.3
export JRUBY_HOME=/Library/Frameworks/JRuby.framework/Versions/Current
export M2_HOME=/Users/$USER/Development/apache-maven-3.0.3
export MACPORTS=/opt/local/bin:/opt/local/sbin
export MONGO_HOME=/usr/local/mongodb
@tcelestino
tcelestino / change-db.sql
Last active January 12, 2018 04:20
wordpress snippets
/* update table wp_post_meta */
UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, '/wp/', '/') WHERE 1=1;
/* update table wp_post */
UPDATE wp_posts SET post_content = REPLACE(post_content, '/wp/', '/') WHERE 1=1
UPDATE wp_posts SET guid = REPLACE(guid, '/wp/', '/') WHERE 1=1
@tcelestino
tcelestino / gist:7136513
Last active December 26, 2015 10:28
using mysql terminal
mysql -u root -p #init mysql
create database dbname; #create database
use dbname; #use database
source pathofsqlfile.sql #import dump sql
@tcelestino
tcelestino / mysql_apache_php_install.sh
Last active December 26, 2015 10:19
install mysql, apache and php on linux
#INSTALLING MYSQL
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install mysql-server mysql-client
#optional
sudo mysqladmin -u root -h localhost password 'mypassword'
sudo mysqladmin -u root -h myhostname password 'mypassword'
#install php library
@tcelestino
tcelestino / flash_js
Created October 7, 2013 19:31
Flash lendo uma função JS
import flash.external.ExternalInterface;
ExternalInterface.addCallback("javascriptFNC", flashFNC);
function flashFNC():void{
//actions
}
----------------------------------------------------------
## javascript
@tcelestino
tcelestino / title.php
Created August 12, 2013 00:38
the best title wordpress
<?php if (is_home () ) {
bloginfo('name');
} elseif ( is_category() ) {
single_cat_title(); echo ' - ' ; bloginfo('name');
} elseif (is_single() ) {
single_post_title();
} elseif (is_page() ) {
bloginfo('name'); echo ': '; single_post_title();
} else {
wp_title('',true);