Pedro's blog: db2, mysql, php, linux and performance


DB2, the date and PHP
04/02/2010, 18:58
Filed under: General | Tags: , , , ,

Here comes the trick:

The common format when I get a date row from the db2 database is:

echo $date; //gets 2010-02-04 18:21:42

How did I make the magic with php:

$date        = strftime(“%d/%m/%Y”, strtotime($date));

echo $date; //gets 04/02/2010

Source: http://php.net/manual/en/function.strftime.php



Disable log on htaccess
30/01/2010, 9:45
Filed under: General,PHP,Security | Tags: , ,

How to disable the logging function of a well defined php script with the htaccess file?

SetEnvIf Request_URI “^/yourdir/yourfile\.php$” dontlog



Latex longtable issue
10/01/2010, 11:37
Filed under: Latex | Tags: ,

I had a problem with a longtable in LaTeX, the margins where so much big and my table was disappearing on the right side:

Longtable issue

The code was:

\begin{longtable}{| c | c | c |}
\rowcolor[rgb]{0.52, 0.52, 0.52} \textbf{Castellano}  & \textbf{Inglés}  & \textbf{Valenciano}  \\ \hline
Artes decorativas /aplicadas    &    Applied Arts    &    Arts decoratives     \\ \hline

\end{longtable}

For fixing it, I had to write the width of every column, and LaTeX did the rest:

\begin{longtable}{| p{0.30\linewidth} | p{0.30\linewidth}  | p{0.29\linewidth}  |}
\rowcolor[rgb]{0.52, 0.52, 0.52} \textbf{Castellano}  & \textbf{Inglés}  & \textbf{Valenciano}  \\ \hline  \endfirsthead
Artes decorativas /aplicadas    &    Applied Arts    &    Arts decoratives     \\ \hline
\end{longtable}

The result:
Longtable issue
And now everything is working properly, I lost the center property but I don’t care.

If you want, you can use the \endhead, \endfoot and \endlastfoot for adding a line on the table with some text before break the line and at the begging of the new page on the continuation of the table, looks cool:

\begin{longtable}{| p{0.30\linewidth} | p{0.30\linewidth} | p{0.29\linewidth} |}
\rowcolor[rgb]{0.52, 0.52, 0.52} \textbf{Castellano} & \textbf{Inglés} & \textbf{Valenciano} \\ \hline \endfirsthead
\caption[Técnicas]{Técnicas} \label{lsttecnicas} \\ \hline
\rowcolor[rgb]{0.52, 0.52, 0.52} \textbf{Castellano} & \textbf{Inglés} & \textbf{Valenciano} \\ \hline \endfirsthead
\hline Continuación de la tabla \\ \hline \hline \endhead
\hline\hline {\scriptsize Continúa en la página siguiente} \\
\hline \endfoot
\hline\endlastfoot

    Primera línea \\ \hline
    Segunda línea \\ \hline
    ...
\end{longtable}

Cheers!



Halt permission on Linux
11/12/2009, 14:58
Filed under: General,GNU/Linux,Security | Tags: , , ,

Hey folks!

I had to give halt and reboot permissions to a linux user, let’s talk about it:

Login as root and:

$visudo

this will open the file /etc/sudoers, then add the following next lines:

%users YOURHOSTHERE = /sbin/halt, /sbin/reboot

And if you don’t want to have to type a password each time then use this line:

%users YOURHOSTHERE = NOPASSWD: /sbin/halt, /sbin/reboot

Save and close the file.

By now, every user in the users group (/etc/group )  is able to run halt and reboot commands:

#sudo /sbin/halt

#sudo /sbin/reboot

If you don’t want to type the sudo command every time, then add this lines to the ~/.bash_profile of every user:

alias halt=’sudo /sbin/halt’
alias reboot=’sudo /sbin/reboot’

Done!

Source: https://www.linuxquestions.org/questions/slackware-14/halt-or-poweroff-permission-for-users-173360/



Listings code on Latex – XSLT
09/12/2009, 17:47
Filed under: Latex | Tags: , , ,

Using the package listings you can add non-formatted text as you would do with \begin{verbatim} but its main aim is to include the source code of any programming language within your document.  Wikibooks

One of the problems of this package is the poor colored syntax with some programming languages, like XML or XSLT, trying language=XML and language=XSLT, the result was… bullshit poor, I prefere to use language=HTML because it has a minimal pretty syntax  and I made some changes, the result:

\lstnewenvironment{fakeXML}[1][]{
\lstset{basicstyle=\scriptsize\sffamily,
linewidth=0.90\linewidth,
numbers=left,
stepnumber=1,
numbersep=10pt,
frame=single,
framerule=1.0pt,
backgroundcolor=\color{darkgray},
language=HTML,
identifierstyle=\color[rgb]{1,0,0},
emph={schema, element, complexType, choice, simpleType, sequence, restriction, pattern}, emphstyle=\color{red},
keywordstyle=\color[rgb]{0,0,1},
commentstyle=\color[rgb]{0.133,0.545,0.133},
stringstyle=\color[rgb]{0.627,0.126,0.941},
morekeywords={xml, ref, xs, version, targetNamespace, minOccurs, maxOccurs}
}\lstset{#1}}{}

\begin{fakeXML}
<?xml version=”1.0″?>
<xs:schema targetNamespace=…

</xs:schema>
\end{fakeXML}

It looks like:

Listings and XML

Another problem solved! 😆



DB2 Ignoring Generated always restriction on loading
05/12/2009, 22:07
Filed under: DB2 | Tags:

A little trick:

CREATE TABLE “THEPROFILE”.”ROL”  (
“ROL_ID” INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (
START WITH +4
INCREMENT BY +1
MINVALUE +0
MAXVALUE +2147483647
NO CYCLE
NO CACHE
NO ORDER ) ,
“ROL_NOMBRE” VARCHAR(50) NOT NULL ,
“ROL_DESCRIPCION” VARCHAR(255) NOT NULL )
IN “USERSPACE1” ;

If you want to load a new row and avoid the GENERATED ALWAYS AS IDENTITY then:

db2 “load from ‘rol.sql’ of del modified by identityoverride insert into db2admin.rol”

We know there are 4 rows on rol.sql.

Be careful with the state of the table space after running the load, maybe you’ll need this command:

db2 “SET INTEGRITY FOR THEPROFILE.ROL IMMEDIATE CHECKED”

Enjoy!



Economics for dummies
30/11/2009, 11:30
Filed under: General | Tags:

I’m a dummy in economics. I admit it. It was a difficult topic for me at University but this topic is getting interesting for me in the last months because of the world crisis and I want to get some knowledge. So, after speaking with my girlfriend (she studied economics “Betriebswirtschaftslehre”), we decided to take a look in Fnac and try to find a book with a general overview of economics.

And… we found it!

Economia para dummiesEconomics for dummies

She thinks is a good overview for a dummy like me, I think I’ll get bored in some chapters, we will see. If you are interested in the book, you can take a look here.



Making mistakes is human
29/11/2009, 14:30
Filed under: General | Tags: , ,

Sometimes, a machine makes a mistake, we find the problem, we fix or replace the machine and we solve the mistake the machine did.

Sometimes, a person makes a mistake, we find the problem, we fix or replace the person… no, we can not fix the person, replace the person? and we solve the mistake the person did.

(more…)



A Course History
28/11/2009, 12:00
Filed under: DB2,Mainframe | Tags: , , , ,

Hey buddies,

since some months I’m looking for an specialized IBM course on DB2, I already got the diploma of this one, but the thing I want is to get some more knowledge around zOS area, some one like this:

DB2 9 for z/OS Database Administration Workshop Part 1 (ES) (I couldn’t because we were 2 persons subscribed on 4 minimum )

Or this one:

DB2 9 for z/OS System Administration (ES) (I couldn’t because I was the only one subscribed…)

So, as my two database possibilities were gone, I decide to move forward and try over the System Performance line:

Basic z/OS Tuning Using the Workload Manager (WLM) (ES)

And yes! I got it on the third round.
Skills taught:
(more…)



WordPress MU, Google Analytics and Google Webmasters tools
27/11/2009, 21:19
Filed under: General | Tags: , , , ,

Hello readers,

I just set up the blog and I want to add it to the huge google’s database,

What I should do?
I had got a little piece of js code from google’s analytics webpage:

Google Analytics section inside WordPress MU<script src=”http://www.google-analytics.com/urchin.js” type=”text/javascript”>
</script>
<script type=”text/javascript”>
_uacct = “UA-xxxxxxx-xx”;
urchinTracker();

</script>

I could add it because WordPress MU has an special section for doing it, now is working, cool.

But… what about google’s webmasters tools ?

Does WordPress MU have any section helping you to verify your blog?

No, it doesn’t, bullshit.

I did try to prepare an static page with the name of the file and the content of the file google’s gave me… didn’t work. I tried to fake a meta tag header somehow and didn’t work neither, I can not upload html files, the admin does not let me modify the headers of the theme… this sucks, does anybody have an idea how to do it? or maybe  it’s not definitely possible, I don’t know, and now I don’t care.

If anybody knows a trick, here I am waiting.

11/04/2012: The UV blogs IT people managing the WMU just added a plugin called HeadMeta and now I can fake the head method for adding my blog to the google’s webmasters tools! did anybody from the IT people read me? Thank you folks!