“Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity.”
– Albert Einstein

Posts Tagged ‘sos’


05
Aug

Gonna redo my work, urrrrrggghh!

  • Thumbnail editor
  • Models RSS
  • Main RSS
  • VXS Banner RSS

Still have an AI integration on the other, :( (

30
Jul

#!/bin/bash 
MyUSER="SET-MYSQL-USER-NAME"  # USERNAME
MyPASS="SET-PASSWORD"         # PASSWORD
MyHOST="localhost"            # Hostname
 
# Linux bin paths 'which' = autodetect
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
CHOWN="$(which chown)"
CHMOD="$(which chmod)"
GZIP="$(which gzip)"
 
# Destination directory
DEST="/backup"
 
# Main directory for backup
MBD="$DEST/mysql"
 
# Get hostname - in target backup filename
HOST="$(hostname)"
 
# Get data in dd-mm-yyyy format
NOW="$(date +"%d-%m-%Y")"
 
# File to store current backup file
FILE=""
# list of databases
DBS=""
 
# DO NOT BACKUP these databases
EXCLUDEDB="test"
 
[ ! -d $MBD ] && mkdir -p $MBD || :
 
# Only root can access it!
$CHOWN 0.0 -R $DEST
$CHMOD 0600 $DEST
 
# Get all database list first
DBS="$($MYSQL -u $MyUSER -h $MyHOST -p$MyPASS -Bse 'show databases')"
 
for db in $DBS
do
  skipdb=-1
  if [ "$EXCLUDEDB" != "" ];
    then
      for i in $EXCLUDEDB
      do
      [ "$db" == "$i" ] && skipdb=1 || :
      done
  fi
 
  if [ "$skipdb" == "-1" ] ; 
    then
      FILE="$MBD/$db.$HOST.$NOW.gz"
      # the meat of everything
      $MYSQLDUMP -u $MyUSER -h $MyHOST -p$MyPASS $db | $GZIP -9 > $FILE
  fi
done

27
Jul

Changes to my wordpress theme so that cattag_related_posts function will work. I’m using Ice theme by miloIIIIVII and inside the theme functions file is the embeded plugin Category Tagging by Bull3t. And guess what, it still reference some column from post2cat table which DOES NOT exists in my version.

It looks like wordpress is not going to release a fix when they dropped post2cat table, starting from the 2.3 release. Or, I just haven’t found their fix on this. I also noticed this when the client I’m working for at Staff Off Shore decided to upgrade his blog site. What I did is modify that block of code and use the term_relationships instead to come up with this SQL and return similar results.

mysql > SELECT DISTINCT p.ID, p.post_title FROM blog_posts p
      > LEFT JOIN blog_term_relationships tr ON p.ID = tr.object_id
      > WHERE p.post_status = 'publish' AND p.ID <> 55
      > AND p.post_type = 'post' AND tr.term_taxonomy_id IN (4)
      > ORDER BY p.post_date DESC LIMIT 5;

I have uploaded a version of cattag_related_posts function and it needs to be patch to any existing theme functions file (functions.php) or the “category-tagging” plugin that still queries on “wp_post2cat” table. This is what I am using, example of which are the items under “Possibly Related” header below this post (not the google of course).

Use it in your template like so, though I think I disabled the $exclude_ids parameter for now, but it should work without it.

1
2
3
4
5
6
7
8
9
10
cattag_related_posts(
	$limit = 5,		# number of posts to return
	$display_posts = true,	# swap values with display_page
	$display_pages = false,	# to get post or page
	$before = '<li>',	# html wrapper
	$after = '</li>',
	$notfound = false,
	$order = 'DATE_DESC',	# DATE_DESC or RANDOM
	$exclude_ids = ''
);

Download: cattag_related_posts.txt