Uncategorized

Uncategorized


String Replace in C++

11.20.2009 | 0 Comments

As I’m just a C++ poser, I don’t know a lot of things programming in this language especially if I have to deal with STL (Standard Template Library). As some of you know, when you’re not using third party libraries in C++, programming gets a little harder (note : my harder is harder than your harder).

So I searched the web and found this solution. Unfortunately, I forgot where I got this. Anyway, the original program doesn’t work.

#include
#include

using namespace std;

int main()
{
string str( "The Horse and the Yokaba" );
string searchString( "Yokaba" );
string replaceString( "Kabayo" );

string::size_type pos = 0;
while ( (pos = str.find(searchString, pos)) != string::npos ) {
str.replace( pos, searchString.size(), replaceString );
pos++;
}
cout << str << endl;
return 0;
}

When I'm using the MString library, it was a breeze. There's a ton of methods that makes things easy but when you need to make your program faster and leaner, you wouldn't want the extra baggage that comes with a third party library. MString is good but it's just brings with it too much things I don't need on my program.

If I have time(which most of the time I spend sleeping), I'll update the post to include a line by line explanation. It's not exactly for you but for me. It's a note to myself. :D

Ciao!


Modified WP Table Prefix in bbPress

8.22.2009 | 1 Comment

If you change your WordPress/WordPress mu table prefix (and thus, renamed the tables too) and you have a bbPress integrated with it, chances are your bbPress will lose its connection with WordPress since the configuration is not in bb-config.php. You’ll need to update the meta tables, too through mysql or phpmyadmin. Here’s the update query.


UPDATE bb_meta
SET meta_value = 'wpmu_'
WHERE meta_key = 'wp_table_prefix';

That’s of course considering your bbPress table is bb_meta and the new prefix for WordPress/WordPress mu is wpmu.


Create New User in CentOS

8.18.2009 | 0 Comments

create the user
syntax
useradd -d [folder_name] -s /bin/bash -c "[name]" [userid]

sample
useradd -d /usr/kwatog/ -s /bin/bash -c "Kwatog Admin" kwatog

set the password
passwd kwatog

clean up later


Tutorial for WordPress Plugin Writing

4.16.2009 | 0 Comments

I’ve been looking for a good wordpress plugin creation tutorial for some time already and though I found quite a number of them, there’s always something missing. What I found were like piece meals and I have to connect the dots myself.

That’s the case until I found Ronald Huereca‘s tutorial posted at DevLounge. His tutorial is concise and direct to the point. It was easy to read and follow and most importantly, it follows the object-oriented approach in wordporess plugin development. Making a plugin in object-oriented way presents a lot of opportunities and lessens the headache in development.

To give you a preview, I’m listing down the table of contents.

Table of Contents: How to Write a WordPress Plugin

  1. How to Write a WordPress Plugin – Introduction
  2. Seven Reasons to Write a WordPress Plugin
  3. How to Get Ideas for WordPress Plugins
  4. Structure of a WordPress Plugin
  5. WordPress Plugin Actions
  6. WordPress Plugin Filters
  7. Constructing a WordPress Plugin Admin Panel
  8. Constructing a WordPress Plugin User’s Panel
  9. WordPress Plugins and Database Interaction
  10. Using JavaScript and CSS with your WordPress Plugin
  11. Using AJAX with your WordPress Plugin
  12. Releasing and Promoting Your WordPress Plugin

To view the tutorial, you can go over to Devlounge’s How to Write a WP Plugin. Alteratively, you can also download the tutorial in pdf form by clicking this link.


Monitor SQL Server DB Processes

4.08.2009 | 0 Comments

If you don’t have DBArtisan or other more advanced SQL Editor, you can use the query below. Take note that you’ll need necessary rights to be able to run it.

select spid, status, blocked, open_tran, waitresource, waittype,
waittime, cmd, lastwaittype, cpu, physical_io,
hostname, hostprocess, loginame, program_name, net_address,
net_library, dbid, ecid, kpid, nt_domain, nt_username, uid, sid,
memusage, last_batch=convert(varchar(26), last_batch,121),
login_time=convert(varchar(26), login_time,121)
from master.dbo.sysprocesses
--where (blocked!=0 or waittype != 0x0000)

If you only want to see those that are blocking or locking, uncomment the last line. One thing that’s lacking here is the list of tables and database objects that each process id is using. That’s important if a user is running stored procedures and you need to know . I’ll provide that later as honestly, I don’t know yet which table holds that information.

I actually contributed this at SQL Reviewer as I don’t see a lot of websites that discusses this. For further reading, you may go to the MSDN website.