rmoff

September 26, 2011

Sourcecode markup tweaks in WordPress

Filed under: wordpress — rmoff @ 14:14

I noticed in Ed Stevens’ blog posting here that some sourcecode he’d posted had certain lines highlighted.

WordPress provides the sourcecode tag for marking up sourcecode in blog posts.
For example:

cd /some/random/folder
ls -l
# do not run this next line!

is much better presented as:

cd /some/random/folder
ls -l
# do not run this next line!

by wrapping it in [sourcecode] tags

I’ve known about the language=’xx’ attribute that you can use with the tag, but Ed’s posting prompted me to check on the syntax and it turns out there a few tweaks one can use. Some of them are illustrated below. The list is taken from WordPress’ Posting Source Code reference page.

[sourcecode] …. [/sourcecode]

#REF: http://en.support.wordpress.com/code/posting-source-code/
#
# This is some dummy source code to illustrate sourcecode posting on wordpress
# Line 2
# Line 3
cd /some/random/folder
ls -l
# do not run this next line!
rm -rf /some

[sourcecode language=bash] …. [/sourcecode]

#REF: http://en.support.wordpress.com/code/posting-source-code/
#
# This is some dummy source code to illustrate sourcecode posting on wordpress
# Line 2
# Line 3
cd /some/random/folder
ls -l
# do not run this next line!
rm -rf /some

[sourcecode gutter=false] …. [/sourcecode]

#REF: http://en.support.wordpress.com/code/posting-source-code/
#
# This is some dummy source code to illustrate sourcecode posting on wordpress
# Line 2
# Line 3
cd /some/random/folder
ls -l
# do not run this next line!
rm -rf /some

[sourcecode collapse=true] …. [/sourcecode]

#REF: http://en.support.wordpress.com/code/posting-source-code/
#
# This is some dummy source code to illustrate sourcecode posting on wordpress
# Line 2
# Line 3
cd /some/random/folder
ls -l
# do not run this next line!
rm -rf /some

[sourcecode highlight=3,5,6,8] …. [/sourcecode]

#REF: http://en.support.wordpress.com/code/posting-source-code/
#
# This is some dummy source code to illustrate sourcecode posting on wordpress
# Line 2
# Line 3
cd /some/random/folder
ls -l
# do not run this next line!
rm -rf /some

[sourcecode firstline=42] …. [/sourcecode]

#REF: http://en.support.wordpress.com/code/posting-source-code/
#
# This is some dummy source code to illustrate sourcecode posting on wordpress
# Line 2
# Line 3
cd /some/random/folder
ls -l
# do not run this next line!
rm -rf /some

[sourcecode padlinenumbers=3] …. [/sourcecode]

#REF: http://en.support.wordpress.com/code/posting-source-code/
#
# This is some dummy source code to illustrate sourcecode posting on wordpress
# Line 2
# Line 3
cd /some/random/folder
ls -l
# do not run this next line!
rm -rf /some

[sourcecode toolbar=false] …. [/sourcecode]

#REF: http://en.support.wordpress.com/code/posting-source-code/
#
# This is some dummy source code to illustrate sourcecode posting on wordpress
# Line 2
# Line 3
cd /some/random/folder
ls -l
# do not run this next line!
rm -rf /some

[sourcecode light=true language=’bash’] …. [/sourcecode]

#REF: http://en.support.wordpress.com/code/posting-source-code/
#
# This is some dummy source code to illustrate sourcecode posting on wordpress
# Line 2
# Line 3
cd /some/random/folder
ls -l
# do not run this next line!
rm -rf /some
Advertisements

Oracle – tnsping – Message 3513 not found; product=NETWORK; facility=TNS

Filed under: windows, XE 11gR2 — rmoff @ 11:38

Short note to record this, as Google drew no hits on it.

Windows XP machine with existing Oracle 11.1 client installation, all working fine.

Installed Oracle 11.2 XE, and started getting these errors:

C:\Windows\System32>tnsping DBNAME

TNS Ping Utility for 32-bit Windows: Version 11.2.0.2.0 - Production on 26-SEP-2011 11:01:11

Copyright (c) 1997, 2010, Oracle.  All rights reserved.

Used parameter files:
C:\app\userid\product\11.1.0\client_1\network\admin\sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Message 3513 not found;  product=NETWORK; facility=TNS
OK (20 msec)

Also got these errors from a previously-functioning ODBC query in Excel when I tried to refresh it:

  • [Microsoft][ODBC driver for Oracle][Oracle]
  • [Microsoft][ODBC Driver Manager] Driver’s SQLSetConnectAttr failed

Google drew a blank on “Message 3513 not found”, but with a bit of guidance from Ed Stevens’ and Charles Hooper’s blogs I checked my PATH variable and found this:

C:\Windows\System32>set
[...]
ORACLE_HOME=C:\app\userid\product\11.1.0\client_1\
[...]
Path=C:\oraclexe\app\oracle\product\11.2.0\server\bin;C:\app\userid\product\11.1.0\client_1\bin;C:\Python27\;C:\Python27\Scripts;C:\OracleBI\server\Bin;C:\OracleBI\web\bin;C:\OracleBI\web\catalogmanager;C:\Program Files\Java\jdk1.6.0_26\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;[...]
[...]
TNS_ADMIN=C:\app\userid\product\11.1.0\client_1\network\admin
[...]

PATH is evaluated in order, left to right. Note that the 11.2 XE binaries are now listed before the 11.1 client binaries.

So whilst the TNS_NAMES and ORACLE_HOME are still for the 11.1 client, it looks like I’m invoking the 11.2 binaries for tnsping and presumably ODBC driver too.

How to fix

Moving the path of 11.2 XE bin to the end of the PATH variable fixed the problem. Presumably also removing the 11.2 XE path would have worked.

I don’t know if there are going to be other ramifications of changing this path variable around (presumably XE would start hitting 11.1 binaries??), but it fixed my immediate problem both with TNSPing and the ODBC queries.

Screenshot

September 16, 2011

Friday miscellany

Filed under: obiee — rmoff @ 11:24

September 13, 2011

DBMS_STATS – GATHER AUTO

Filed under: dbms_stats, oracle — rmoff @ 17:28

In Oracle 11g, the DBMS_STATS procedure GATHER_SCHEMA_STATS takes a parameter ‘options’ which defines the scope of the objects processed by the procedure call, as well as the action. It can be either GATHER or LIST (gather the stats, or list out the objects to be touched, respectively), and AUTO, STALE or EMPTY (defining the object selection to process).

  • GATHER on its own will gather stats on all objects in the schema
  • GATHER EMPTY / LIST EMPTY is self-explanatory – objects with no statistics.
  • GATHER STALE / LIST STALE is pretty obvious too – objects that have stale statistics (i.e. have had 10% change to them since statistics were last gathered). NB this 10% can be changed at an object/schema/DB level.
  • However, the documentation is ambiguous as to the precise function of GATHER AUTO / LIST AUTO.

There’s even a MOS note, “Differences between GATHER STALE and GATHER AUTO (Doc ID 228186.1)”, which strangely enough – given the precision of its title – doesn’t really explain the difference.

I’m quite fastidious about these things, particular in the documentation which I believe ought to be beyond fault. The frustrating thing for me is the sprinkling of fairy dust approach to describing the parameter:

  • “Oracle implicitly determines which objects” — ok, but how does it “implicitly determine”, what algorithm sits behind it?
  • “Oracle[…]determines how to gather” — does it intelligently determine how to gather the stats for each object’s characteristics, or does it passively fallback to the defaults? There’s a difference, since one is a good starting point and the other would be in theory an ideal.

Why does this matter? Because statistics matter so much, and so a stats gathering strategy that is accurate and efficient is important. We can only do this if we understand exactly what the product is doing. GIGO, and all that.

Reading, and re-reading, the documentation, I think the explanation is this:

  • GATHER AUTO gathers stats on objects with stats which are either STALE or EMPTY, i.e. the combined object list of
    • GATHER STALE
    • GATHER EMPTY
  • GATHER AUTO automagically defines all the other parameters relating to how the statistics are gathered – method_opt, estimate_percent, etc. User-specified values for these parameters are just ignored.

I’ve raised an SR to try and get proper clarification, and will update here if/when I find out.

UPDATE Oracle confirmed in an SR that “Gather AUTO Processes stale objects + objects without statistics (empty)”

Note Doc ID 1073120.1 which details method_opt that will be used in GATHER AUTO.

Finally, don’t forget that representative statistics != non-stale statistics. None other than Ask Tom points this out.

Just because statistics are not “stale”, doesn’t mean that are representative of your data. You should always understand your data and make sure you’re giving the CBO the most accurate information you can about the data.

September 12, 2011

Using preupgrade to upgrade Fedora 14 to Fedora 15 – proxy errors

Filed under: fedora, linux — rmoff @ 09:26

When using preupgrade to upgrade an existing Fedora 14 installation to Fedora 15, the following two errors were encountered:

  • Failed to fetch release info
  • No groups available in any repository

The box sits on a network behind a proxy out to the web.

The resolution was to make sure that environment variables http_proxy and https_proxy are set:

export http_proxy=http://user:password@proxyserver:port
export https_proxy=http://user:password@proxyserver:port

Make sure you do this from the user from which you run preupgrade.

Update

The upgrade is kapput. On reboot I get:
The root for the previously installed system was not found

Lots of hits on the bug database but none resolving.
So still stuck on F14 until I get chance to resolve this, probably just a clean install.

Update 2

I’ve successfully upgraded two other F14 installations to F15 using preupgrade, so the problems above must be unique to the installation in question.

September 8, 2011

Labelling Time axes in Excel

Filed under: Excel, hack, visualisation — rmoff @ 09:53

Excel may send chills down the spine of us when we hear users talking about its [ab]use, but it has its place in the toolset. For my money, it is a very good tool for knocking out graphs which look decent. Of course, rrdtool is my geek tool of choice for dynamic long-term graphing, but when doing scratch PoC work, I normally fall back to Excel.

One thing which has frustrated me over time is, well, time, and Excel’s handling thereof. How many times (these puns are getting tiresome already) have you seen an axis like this and gnashed your teeth?

Excel's default labelling of time axes sucks

Looking at the axis options shows some decimals, with no apparent bearing on the times shown on the axis:

By virtue of using Excel for quick ‘n dirty graphing, I normally don’t have the time to figure this out properly. I finally cracked, and I’m glad I did. The answer is very simple.

Time’s in Excel are based on fractions of 1 day. So, with a number of 1 = 24 hours, we can work backwards:

  • 1/2 is going to be half a day, twelve hours = 0.5
  • 1/24 = one hour = 0.04166666666667
  • 1/24/2 = Half an hour = 0.02083333333333
  • 1/24/2/2 = Quarter of an hour = 0.010416666666666667
  • 1/24/60 = One minute = 0.000694444444

This is a good example of understandable backend functionality (storing times as a plain number) ought to be shielded from the end user, and the interface design has fallen one step short. Excel knows the data is Time, and good interface would at the very least offer the option to define axes in terms of time, if not hide the decimals entirely.

Still, making use of what we have, we can still get Excel to behave, it’s just a bit labourious:
You want a graph with a maximum of 1 hour, major lines every fifteen minutes, and minor at 5 minutes? No problem.

Sensible time axis labelling in Excel

So next time you’re graphing a time series in Excel, fire up Calc and work out your fractions, for some proper time axis labelling.

Blog at WordPress.com.