tag:blogger.com,1999:blog-8126533881227135052024-02-02T13:51:23.929-08:00My [not so] secret knowledgeUnknownnoreply@blogger.comBlogger26125tag:blogger.com,1999:blog-812653388122713505.post-70180764336239307132013-11-29T19:23:00.003-08:002013-11-29T19:23:43.143-08:00Setting textarea height adjusted to the contentsI have a page I would like to print out having <textarea> printed as well.<br />
I would like to have this <textarea> having maximum width, and minimum height, so where there is no data it is only one line, but in case the data spans to, let's say, 10 rows, it expands <textarea> to 10 rows, and no scrollbar appears.<br />
<br />
This is what I have found that works for me:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;"> $(".tarows").each(function(){</span><br />
<span style="font-family: Courier New, Courier, monospace;"> $(this).height(0) ;</span><br />
<span style="font-family: Courier New, Courier, monospace;"> $(this).height($(this).prop("scrollHeight") + "px") ;</span><br />
<span style="font-family: Courier New, Courier, monospace;"> }) ;
</span><br />
<br />
- or similar using pure javascript:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;"> element.style.height=0;</span><br />
<span style="font-family: Courier New, Courier, monospace;"> element.style.height=element.scrollHeight+'px';</span><br />
<br />
<br />
This way, I can define my textarea (using class tarows) without cols or rows, and say in css to make it 100% width:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">.tarows {</span><br />
<span style="font-family: Courier New, Courier, monospace;"> width: 100%; </span><br />
<span style="font-family: Courier New, Courier, monospace;">}</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><textarea class="tarows">multiline text which will be shown on the whole width of the page, and as many rows as needed.</textarea></span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-812653388122713505.post-53590989964001059952013-06-05T11:43:00.001-07:002013-06-05T11:43:24.475-07:00logrotate<tt>logrotate -f /etc/logrotate.conf</tt><br/>
Nothing more to say.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-812653388122713505.post-1521556158232000952012-01-04T10:17:00.000-08:002012-01-04T10:17:22.318-08:00mediawiki: There seems to be a problem with your login session; this action has been canceled as a precaution against session hijacking. Go back to the previous page, reload that page and then try again<p><u>If you see:</u></p>
<p><b>There seems to be a problem with your login session; this action has been canceled as a precaution against session hijacking. Go back to the previous page, reload that page and then try again
</b></p>
<p>Then the problem is with your file system.</p>
<p>Check the status of the file system that holds your /tmp directory.</p>
<p>I bet it is full.</p>
<p>Clean the /tmp directory or delete unneeded files/directories in the file system and you will be good to go.</p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-812653388122713505.post-46071476780351077832011-11-26T20:39:00.001-08:002011-11-26T20:48:54.110-08:00Life is Worth Living, CD 11 order of mp3Something out of the ordinary of this blog...<br />
The <a href='http://www.saintjoe.com/prodinfo.asp?number=45MP3'>"Life is Worth Living, CD 11"</a> has incorrect mp3 order (sequence.)<br />
Just in case someone decided to look for proper here is the correct one:<br />
<br />
<ol>
<li>Life is worth livingk (0).mp3</li>
<li>Life is worth livingk (2).mp3</li>
<li>Life is worth livingk (b14).mp3</li>
<li>Life is worth livingk (3).mp3</li>
<li>Life is worth livingk (b12).mp3</li>
<li>Life is worth livingk (b13).mp3</li>
<li>Life is worth livingk (4).mp3</li>
<li>Life is worth livingk (5).mp3</li>
<li>Life is worth livingk (6).mp3</li>
<li>Life is worth livingk (7).mp3</li>
<li>Life is worth livingk (1).mp3</li>
<li>Life is worth livingk (8).mp3</li>
<li>Life is worth livingk (9).mp3</li>
<li>Life is worth livingk (b10).mp3</li>
<li>Life is worth livingk (b11).mp3</li>
</ol>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-812653388122713505.post-91987312216152963832011-09-16T10:53:00.000-07:002011-09-16T10:53:14.035-07:00GDB - Accessing deque and queue<br />
In O1 mode some of the functions are optimized out and it is impossible to call them.<br />
In case of deque and queue (which is build over deque) it is a bummer for the size() method is calculated.<br />
<br />
After finding some examples on the Internet we found nothing usable (I guess because our gcc was using different deque memory structure.)<br />
<br />
So we created a new version.<br />
<br />
pdequeue_info variable<br />
- Shows size, first, and last element<br />
<br />
pdequeue variable [firstidx [lastidx]]<br />
- Shows contents or a range.<br />
<br />
<tt>
define pdequeue_info<br />
set $var=($arg0)<br />
set $sizeof=sizeof( **$var._M_impl._M_start._M_node )<br />
set $size=$sizeof < 512 ? ( 512 / $sizeof ) : 1<br />
set $i=0<br />
while $i < $var._M_impl._M_map_size && $var._M_impl._M_map[ $i ] == 0<br />
set $i++<br />
end<br />
set $rv = 0<br />
while $i < $var._M_impl._M_map_size && $var._M_impl._M_map[ $i ] != $var._M_impl._M_finish._M_first<br />
set $rv += $size<br />
set $i++<br />
end<br />
if $var._M_impl._M_map[ $i ] != 0<br />
set $rv += $var._M_impl._M_finish._M_cur - $var._M_impl._M_finish._M_first<br />
end<br />
printf "size : "<br />
p $rv<br />
if $rv > 0<br />
printf "first : "<br />
p *$var._M_impl._M_start._M_cur<br />
if $rv > 1<br />
printf "last : "<br />
p *( $var._M_impl._M_finish._M_cur - 1 )<br />
end<br />
end<br />
end<br />
<br />
define __pdeque_show_group<br />
set $cur=($arg0)<br />
set $size=($arg1)<br />
set $f=($arg2)<br />
set $l=($arg3)<br />
set $j=0<br />
while $j < $size && $n <= $l<br />
if $n >= $f<br />
printf "[%i] : ", $n<br />
p *$cur<br />
end<br />
set $cur++<br />
set $j++<br />
set $n++<br />
end<br />
end<br />
define pdequeue<br />
set $var=($arg0)<br />
set $f=-1<br />
set $l=9999999999<br />
if $argc == 2<br />
set $f=($arg1)<br />
set $l=$f<br />
end<br />
if $argc == 3<br />
set $f=($arg1)<br />
set $l=($arg2)<br />
end<br />
set $sizeof=sizeof( **$var._M_impl._M_start._M_node )<br />
set $size=$sizeof < 512 ? ( 512 / $sizeof ) : 1<br />
set $i=0<br />
while $i < $var._M_impl._M_map_size && $var._M_impl._M_map[ $i ] == 0<br />
set $i++<br />
end<br />
set $n=0<br />
while $i < $var._M_impl._M_map_size && $var._M_impl._M_map[ $i ] != $var._M_impl._M_finish._M_first && $n <= $l<br />
__pdeque_show_group $var._M_impl._M_map[$i] $size $f $l<br />
set $i++<br />
end<br />
if $var._M_impl._M_map[ $i ] != 0 && $n <= $l<br />
__pdeque_show_group $var._M_impl._M_map[$i] $var._M_impl._M_finish._M_cur-$var._M_impl._M_finish._M_first $f $l<br />
end<br />
end<br />
<br />
</tt>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-812653388122713505.post-74020305023905006202011-06-15T12:45:00.000-07:002014-01-09T19:09:55.229-08:00valgrind - dowloading, building and installingFirst, I need to post all the links that will allow you to get to the creators information:<br />
<br />
* <b>WWW</b>: <a href="http://valgrind.org/">http://valgrind.org</a><br />
* <b>Manual</b>: <a href="http://valgrind.org/docs/manual/valgrind_manual.pdf">http://valgrind.org/docs/manual/valgrind_manual.pdf</a><br />
* <b>Source</b>: <a href="http://valgrind.org/downloads">http://valgrind.org/downloads</a><br />
* <b>Building Instruction</b>: <a href="http://valgrind.org/docs/manual/dist.readme.html">http://valgrind.org/docs/manual/dist.readme.html</a><br />
<br />
<b>Building</b><br />
* Download the source and put into your <b>home </b>account. Let's assume it is the valgrind-3.6.1 version.<br />
Run these commands:<br />
<code><br />
vver=valgrind-3.6.1<br />
tar xf $vver.tar.bz2<br />
cd $vver<br />
ulimit -u 100 # ./configure has a bug ...<br />
./configure --prefix=$HOME/valgrind # You need that in order to run make install without root privileges<br />
make<br />
make install<br />
cd $HOME/valgrind/bin<br />
./valgrind ls -l # see if it bombs out. If it does not you are good to go<br />
</code><br />
<br />
Now, what you have is a $HOME/valgrind directory. If this is place where you want to use it then you are ready. The only one thing you need to do is set your path: <b>export PATH=$HOME/valgrind/bin:$PATH</b><br />
<br />
<b>Ok... and what about if you need this valgrind now on a machine that does not have gcc?</b><br />
The only thing you need to do is to pack the whole $HOME/valgrind directory, and copy it over to the destination machine.<br />
The only caveat is that it has to be put into <b>exactly the same directory</b> as it was built in or else you will see this nice message:<br />
<b><span style="color: red;">valgrind: failed to start tool 'memcheck' for platform 'amd64-linux': No such file or directory</span></b><br />
<br />
<b>Solution</b> - ln -s $HOME/valgrind path-to-valgrind-on-the-build-machine<br />
Example: ln -s $HOME/valgrind /home/myhome/valgrindUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-812653388122713505.post-14262327552290618292010-05-16T20:45:00.001-07:002010-05-16T20:54:56.583-07:00Internal Server Error when password protecting directoryDo you see something like that:???<br /><br /><span style="font-weight:bold;color:red">Internal Server Error<br />The server encountered an internal error or misconfiguration and was unable to complete your request.<br /><br />Please contact the server administrator, webmaster@blahblah and inform them of the time the error occurred, and anything you might have done that may have caused the error.<br /><br />More information about this error may be available in the server error log.<br /><br />Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.</span><br /><br />There is a very simple explanation but it took me lots of time to discover the reason. Well, I'm not as good as I would like to be ;)<br /><br />The reason -> FILE PERMISSION!!!<br /><br />All directories have to have +xr access for the web server. You may have to make o+xr them.<br />Also the .htpasswd and .htaccess have to be accessible for the web browser.<br /><br />Here is my .htaccess in the directory I want to have password protected:<br /><code><br />AuthUserFile /home/myhome/.htpasswds/.htpasswd<br />AuthName "Login Area"<br />AuthType Basic<br />require valid-user<br /></code><br /><br />Since the web server is 'hosted', so the best thing to do is to run the phpinfo() on the web browser (create p.php file and put <b><?php phpinfo(); ?></b> in it) and look for DOCUMENT_ROOT to see where really are your web files located.<br />Make sure that all the directories leading to .htpasswd and .htaccess are having proper 'read/execute' attributes (644)Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-812653388122713505.post-28928688045725232232010-05-11T19:16:00.000-07:002010-05-11T19:17:31.593-07:00Google Calendar compatible Catholic Calendar in UShttp://www.google.com/calendar/embed?src=vfc9s2tq7ugm3qutnm823pu9ec@group.calendar.google.com&ctz=America/New_YorkUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-812653388122713505.post-22579619203619191672010-01-14T07:46:00.001-08:002010-01-14T07:53:24.291-08:00ls using boostWant to use boost and get list of files matching a mask. The same list you would obtain running ls in the command prompt?<br /><br />The idea is to have something like this:<br /><br /><listing><br /> BOOST_FOREACH( const std::string& fname, ls( "./*.cpp" ))<br /> std::cout << fname << std::endl ;<br /></listing><br /><br />So here is the solution. One function and one helper function (to_regex_copy()):<br /><br /><listing><br />std::string to_regex_copy( std::string mask )<br />{<br /> std::string rv = boost::regex_replace( boost::regex_replace( boost::regex_replace( mask, boost::regex( "\\." ), "\\\\." ), boost::regex( "\\?" ), "\\." ), boost::regex( "\\*" ), "\\.*" ) ;<br /> return rv ;<br />}<br /><br />std::vector< std::string > ls( const char* pcszMask )<br />{<br /> namespace fs = boost::filesystem ;<br /> boost::filesystem::path path ;<br /> boost::regex mask ;<br /> if ( fs::is_directory( pcszMask ))<br /> {<br /> path = pcszMask ;<br /> mask = ".*" ;<br /> }<br /> else<br /> {<br /> path = fs::path( pcszMask ).remove_filename() ;<br /> mask = to_regex_copy( fs::path( pcszMask ).filename()) ;<br /> }<br /><br /> std::vector< std::string > rv ;<br /> try<br /> {<br /> for ( fs::directory_iterator p(path), e; p!=e; ++p)<br /> {<br /> if ( boost::regex_match( p->filename(), mask ))<br /> rv.push_back( p->filename()) ;<br /> }<br /> }<br /> catch( ... )<br /> {<br /> }<br /><br /> return rv ;<br />}<br /></listing>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-812653388122713505.post-60510039803833242412010-01-12T14:03:00.000-08:002016-08-08T13:54:05.329-07:00Profiling shared library on Linux using sprofIt's not as easy as one would/should expect. <span style="font-size: x-small;">(Read <a href="http://greg-n-blog.blogspot.com/2011/06/valgrind-dowloading-building-and.html">here about valgrind</a> if you don't want to use sprof.)</span><br />
<br />
<span style="font-weight: bold;">First</span> - FORGET ABOUT gprof. gprof is used for the applications but will NOT WORK for shared libraries. Sorry about that. I learned about it the hard way. What you need to use is <span style="font-weight: bold;">sprof</span>.<br />
<br />
<span style="font-weight: bold;">Second</span> - sprof may make you bite your fingers if your glibc library is not up-to-date. It will be displaying the nasty message: <span style="font-weight: bold;">"sprof: failed to load shared object"<span style="font-style: italic;"></span></span><br />
If this is what you see then you HAVE TO update your glibc. Read about the bug: <a href="http://rhn.redhat.com/errata/RHBA-2009-0080.html">here</a>. It may not be as simple to upgrade as well... If I have time I will write how to do it through the .iso file (if you have one.)<br />
<br />
<span style="font-weight: bold;">Third</span> - Yes, as it is not enough, there is an other surprize! The -pg option works well for gprof, but screws up things for sprof! You need to remove this option in order to get proper results from the shared libraries. Otherwise you will get only zeroes as the execution time for the functions.<br />
<br />
So, at the end, what to do?<br />
<br />
Assuming you have the patch installed or you have glibc-2.5-34 or newer version installed do as follows (the best, in my opinion, way, assuming you have write access to the current directory.)<br />
<br />
1) Compile your shared library (libmylib.so) in debug (-g) mode. No -pg.<br />
2) export LD_PROFILE_OUTPUT=`pwd`<br />
3) export LD_PROFILE=libmylib.so<br />
4) rm -f $LD_PROFILE.profile<br />
4) execute your program that loads libmylib.so<br />
5) sprof PATH-TO-LIB/$LD_PROFILE $LD_PROFILE.profile -p >log<br />
6) See the log.<br />
<br />
I hope it will help you.<br />
<br />Unknownnoreply@blogger.com4tag:blogger.com,1999:blog-812653388122713505.post-51497389776794082582009-10-09T09:30:00.000-07:002014-01-09T19:08:35.240-08:00ssh, scp password-less connectionBelow is possibly the simplest way it can be accomplished.<br />
Simply enter <b>username@ip-address</b>, when asked after running this one-liner below:<br />
<pre><span style="color: blue; font-family: Courier New, Courier, monospace;">printf "enter username@ip-address: " ; read UIP ; ssh $UIP "mkdir .ssh 2>/dev/null ; echo $(cat $HOME/.ssh/id_rsa.pub) >>.ssh/authorized_keys ; chmod 700 .ssh ; chmod 600 .ssh/authorized_keys" ; echo "hostname=$(ssh $UIP hostname)"</span>
</pre>
You should be done.<br />
If everything was okay you should see the <b><i>hostname</i></b> command result run on the target.<br />
From this moment, you can run your commands on the remote host by executing like this:<br />
<pre><span style="color: blue; font-family: Courier New, Courier, monospace;">ssh username@ip-address "your command"</span>
</pre>
or copying files like that:
<br />
<pre><span style="color: blue; font-family: Courier New, Courier, monospace;">scp myfile username@ip-address:</span>
</pre>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-812653388122713505.post-30263402717673243902008-09-25T14:18:00.000-07:002008-09-25T14:22:39.847-07:00How do I find the name of the current shell that I am working inThere is a command that will work on all platforms I tested (HP-UX, SunOS, Linux, MacOS) and shells (sh,ksh,bash,csh,zsh)<br /><br />ps -p $$ | grep $$ | awk '{ print $NF }'<br /><br />Be aware that the shell name can be bash or -bashUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-812653388122713505.post-10197360844790689182008-06-24T12:03:00.000-07:002008-06-24T12:08:14.533-07:00At least one secondary cursor must be specified to DB->join error 22Never found this problem on the Internet? Does it mean nobody except me run into it?<br /><br />I have tested BerkeleyDB BTree 4.7.25 (from Oracle now) and when running a simple test described in their doc I got the following when opening (creating) a database:<br /><br /><font color='red'>At least one secondary cursor must be specified to DB->join error 22</font><br /><br />After hours of searching here is what I found - the standard installation that comes the btree with is precompiled with a different Visual Studio that has a problem with VS 6.0 I was using. Even though I was able to download the dll (the release mode because the <strong>debug mode was wrong</strong> - shipped with improper MS nondebug libraries) the opening was returning this wrong message.<br /><br />Only after opening the .dsw that came with the sources, and rebuilding it with VS 6.0 all went okay.<br /><br />I hope it will help someone...Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-812653388122713505.post-19555047556625971672008-06-06T12:01:00.000-07:002008-06-17T22:16:38.285-07:00New download of the cvs repository on WindowsI have moved to a new laptop, and I had to get all the data from the cvs repository to this new one.<br />I wasn't even expecting so many problems with the WinCVS application to have!<br />No, it's not that WinCVS is bad. It's great. The point is that It gives so many options to accomodate so many users behaviours that at someome moment these options became a burden!<br /><br />So I have finally decided to describe, step-by-step all the operations one needs to do in order to download new repository to his/her place.<br />This list is for cvs windows only.<br />I may to do this for Linux/Unix as well some time.<br />If you want to install WinCVS then, please, search on the Internet, wait for my new blog, or write to me in the comments.<br /><br /><pre><span style="font-size:70%;"><br />RUN: <<<WinCVS>>><br /><br />MENU: <<<Admin/Login...>>><br />EDIT: <<<CVSROOT:>>> - avoid using <<<...>>> It's overly confusing. It is better to enter the path:<br /> :pserver;username=USERNAME;hostname=HOSTNAME:REPOSITORY<br /> EXAMPLE: :pserver;username=john;hostname=our.server.org:/Projects<br /><br />BUTTON: <<<OK>>><br /> The CVS will ask you for the password which will be stored at your machine<br /> in an encrypted form and will be used for communication every time you<br /> access the repository, but until you click MENU: <<<Admin/Logout>>><br />MENU: <<<Remote/Checkout module...>>><br />DIALOG: <<<Checkout settings>>><br /> EDIT: <<<Module name and path on the server:>>><br /> ProjectAlpha<br /> EDIT: <<<Local folder to checkout to:>>><br /> CHANGE IT so it points at the ROOT directory where the ProjectAlpha directory will be created.<br /> EXAMPLE: c:\JohnsProject\ (yes, add the backslash at the end!)<br /><br /> NOTE: If you DO NOT WANT to create the ProjectAlpha\ directory in the c:\JohnsProject one then you need to do:<br /> CHECKBOX: <<<Check out into directory:>>> Turn in ON<br /> EDIT: <<<Check out into directory:>>><br /> JohnsProject<br /> COMBOBOX: <<<CVSROOT:>>><br /> Drop down menu and select the last one that you have enteted a few steps above.<br /> BUTTON: <<<OK>>><br /> Off you go!<br /></span></pre><br /><br /></p><br />-------------------------------------<br />After this operation, you will have your selected directory (c:\JohnsProject\ProjectAlpha, or c:\JohnsProject only) populated with the data.<br />from the server.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-812653388122713505.post-17288745666201961632008-06-05T23:31:00.000-07:002008-06-06T12:12:05.985-07:00Sending an email from PHP (on Windows too.)Yey, finally got something that really works.<br />It's not my stuff, but I was able to found it after a long time search!<br />Here is the link to <a href="http://sourceforge.net/project/showfiles.php?group_id=26031&package_id=252700&release_id=604592">sourceForge.net</a>, to the page that hosts php Mailer for PHP 5 for Windows, and looks like for Unix too. If the link does not work then search for the word phpMailer.<br /><br />The easiest way to install the stuff is to do as follows (example on Windows, with assumption that you have your php installed in the c:\php directory.)<br /><br />> <strong>mkdir c:\php\mailer</strong><br /><strong>Unzip</strong> phpMailer_v2.1.zip into c:\php\mailer<br />> <strong>notepad.exe c:\php\php.ini</strong><br />Add at the very end:<br /> <strong>include_path=".;c:\php\mailer"</strong><br /><br />Youre done!<br /><br />Now, example:<br /><pre>><span style="font-size:70%;"><br /><?php<br />require_once( "class.phpmailer.php" ) ;<br /><br />$mail = new PHPMailer() ;<br />$mail->IsSMTP() ;<br />$mail->Host = "smtp.myserver.com:587" ;<br />$mail->SMTPAuth = true ;<br />$mail->Username = "username" ;<br />$mail->Password = "password" ;<br />$mail->From = "me@myserver.com" ;<br />$mail->FromName = "It is me!" ;<br />$mail->AddAddress( "testaddress@theirserver.com", "Poor Receiver" ) ;<br />$mail->AddReplyTo( "me@myserver.com", "do-not-reply" ) ;<br />$mail->AddAttachment( "c:\\mydog.jpg", "Isn't she cute?" ) ;<br />$mail->Subject = "Sorry for this test email!" ;<br />$mail->IsHTML( true ) ;<br />$mail->Body = file_get_contents( "c:\\myemail.html" ) ;<br />$mail->AltBody = "non-HTML mail client? Where are you from?" ;<br /><br />if( !$mail->Send())<br /> printf( "Sending Error: " . $mail->ErrorInfo . "\n" ) ;<br />else<br /> printf( "Message has been sent successfully.\n" ) ;<br />?><br /></span></pre>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-812653388122713505.post-80970753272090287312008-05-30T08:54:00.000-07:002008-06-24T20:25:59.431-07:00Script Shell Syntax checkingI'm writing a lot of stuff in shell (Korn,Bourne,Bash) and I had a need for syntax checker in the build time. Something I could use either in the command line (like a compiler) or in the make time which should stop the build whenever there is a syntax error in my script.<br /><br />Here is what I came up to. Simply copy/paste the code below to a file named shck.sh (or whatever you wish to call it), do chmod+x shck.sh and off you go!<br /><br />Usage:<br />shck.sh myscript.sh<br />-or-<br />cat myscript.sh | shck.sh<br /><br />You can also use it in the makefile. It will return value 1 if there was an error.<br />-----------------------------------------------------<br />shck_return() {<br /> return $1<br />}<br />shck_errno=0<br />echo "set -n ">random.$$.sh<br />cat $1 >>random.$$.sh<br />chmod +x random.$$.sh<br />./random.$$.sh >errors.$$.err 2>errors.$$.err<br />rm -f random.$$.sh<br />grep -v ": warning: line" errors.$$.err | sed -e s/random.$$.sh/$1/g >errors.$$.err2<br />[ -s errors.$$.err2 ] && {<br /> shck_errno=1<br /> cat errors.$$.err2<br />}<br />rm -f errors.$$.err errors.$$.err2<br />shck_return $shck_errnoUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-812653388122713505.post-61213292024589773152008-05-28T22:14:00.001-07:002008-05-28T22:32:47.138-07:00Opening unopenable attachments in Microsoft OutlookThe Microsoft Outlook software, starting, as I believe, from version 2003, turned opening some of the attachments for good. If you received, for example, an .mdb file (from Microsoft Access,) then you will only see that you got it, but you won't be able to copy it to the hard drive. Don't try searching in the options as suggested in the email. There is no option to turn the ability to detach the attachment on.<br />Microsoft says it clearly - because it is one of the most popular applications for managing emails, it has been constantly under attach by the hackers, so to 'save' their customers, they turned several options off for good. There is a workaround though. You can ask the sender to send you the file again, but ask him/her to rename the extension of the file or to zip/rar it. If such option is not a good one, or at least not for the very moment because you're in a hurry, there the following solution:<br /><br />Run <strong>regedit</strong>: WARNING, WARNING: These operations are dangerous, so if you're not feeling secure, don't play with regedit. Screwing up in this file may screw up with your Windows installation and ultimatelly you may have to reinstall your OS!!!!<br /><br />Open <strong>HKEY_CURRENT_USER\Software\Microsoft\Office\<span style="color:#ff6600;">11.0</span>\Outlook\Security</strong><br />(<span style="color:#ff6600;">11.0</span> is for Outlook 2003)<br /><br />Create or add a New String Value under this key with the name: <strong>Level1Remove</strong><br /><br />Enter the file extensions separated with the semicolon (;) that you would like to support in the attachment. The file extensions should start with a coma.<br /><br /><strong><u>EXAMPLE:</u></strong><br />Level1Remove .mdb;.xlsx<br /><br /><u>Typical errors:</u><br />- forgetting to put a dot in the front of the extension<br />- putting spaces into the Level1Remove value<br />- Putting Level1Remove string into improper place in registry<br />- Creating a KEY instead of a <strong>STRING VALUE</strong> in registry.<br /><br />When you are done, close the regedit program, close your Microsoft Outlook application, and open it again. From that moment, the files with the extensions you have just added into registry will be available for you.<br /><br />Make sure you don't overdo and don't add others files 'just in case'. You may put yourself in danger by allowing to accept .exe, .bat, .js and other executable files. Use your head!Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-812653388122713505.post-48036658079642788872008-05-28T21:58:00.000-07:002008-05-28T22:10:58.376-07:00jpg - changing internal date and time stampOoops. I have set an improper date on my digital camera and now, Picassa shows my pictures in improper order. I take care of setting the date and time stamp of the file but even though, Picassa puts my new pictures amont the last year ones.<br /><br />I started searching for a tool that would allow me to change the internal jpeg (jpg) date and time stamps, and I have run onto a very nice one - file Tweak (<a href="http://filetweak.com/">http://filetweak.com</a>) The sad part this tool, being really an excellent Windows addition to the file properties dialog box, cost money, and I didn't want to spend money to, from time to time, fixing my mistakes. (You can download a limited in time and functionality filetweak from them.)<br /><br />I have decided to take a closer look to the jpg file and check if I can change the date and time opening the file in binary mode (I use Visual Studio, but you can find other free tools that can do it for you.)<br /><br />What a surprize - the date time is stored in DOS open format!<br />Example: 2008:05:25 22:36:40<br /><br />In my jpeg files are three dates (when the picture has been taken, when was digitalized and when was modified.)<br /><br />The easiest way then, to change the timestamp of your jpeg files is:<br /><br />Search for the year your picture has been taken (Right-click on the file, Properties,Summary tab,Make sure Advanced button is on, Search for Date Picture Taken.)<br />Simply, using any binary editor, modify the date and/or time of the jpg files (up to three places to be changed) and save the file. You're done. Picassa and you will be happy :)Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-812653388122713505.post-71850399207882103912008-05-24T20:51:00.001-07:002008-05-24T21:02:56.230-07:00Running a command for each value comming back from an ODBC query in PHPI have a need to read an ODBC datasource and run a query on a particual table. For each unique value of the table, I need to run a command in the shell.<br /><br /><strong>Here is anexample:</strong><br /><br /><pre><span style="font-size:70%;"><br /><?php<br /> $values = Array() ;<br /> $command = "echo" ; /* for the example purposes the command is echo */<br /> $columnName = "state" ; /* just for this example */<br /><br /> $hdbc = odbc_connect ( "dsn-name", NULL, NULL ) ;<br /> if ( $hdbc != NULL )<br /> {<br /> $hstmt = odbc_prepare(<br /> $hdbc<br /> , "select distinct " . $columnName . " from tablename"<br /> ) ;<br /> if ( $hstmt != NULL )<br /> if ( odbc_execute( $hstmt ))<br /> {<br /> while ( odbc_fetch_row( $hstmt ))<br /> $values[] = odbc_result( $hstmt, 1 ) ;<br /> }<br /> else<br /> printf( "*** Unable to execute\n" ) ;<br /> else<br /> printf( "*** Unable to prepare the query.\n" ) ;<br /><br /> odbc_close( $hdbc ) ;<br /> }<br /> else<br /> printf( "*** Unable to connect\n" ) ;<br /><br /> foreach ( $values as $value )<br /> system( $command . " \"" . $value . "\"" ) ;<br />?><br /></span></pre>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-812653388122713505.post-88562767543561739222008-05-23T21:15:00.000-07:002008-05-23T21:28:47.807-07:00Publishing an Excel table as static html using jscript.Oh man! I have worked on it a few days, posted numerous questions on various newsgroups, spent hours on the Internet and in a book store, and finaly I got what I needed!<br /><br /><strong>Requirement:</strong><br />I have a sheet (Sheet1) in my xlsx document (Excel 2007) which I wanted to save as a static html page using.<br />I want to use jscript run in the command line, so I could automate the process.<br />I don't want to use SaveAs( ..., 44 ) method because it creates the sheet name at the bottom.<br />I also don't want to have the ActiveX embedded into the page (no dynamic html.)<br /><br />Assuming that the document is c:\mydoc\test.xlsx, I want to generate c:\mydoc\test.html file.<br /><br /><strong>Here is the code of doit.js file:</strong><br /><br />ea = new ActiveXObject( "Excel.Application" ) ;<br />ea.DisplayAlerts = 0 ; /* Don't want to see any questions on the screen! */<br />wb = ea.Workbooks.Open( "c:\\mydoc\\test.xlsx" ) ;<br />po = wb.PublishObjects ;<br />po.Add( 1, "c:\\mydoc\\test.html", "Sheet1" ) ; /* 1 == static html. */<br />po.Item( 1 ).Publish( true ) ; /* Yahoo! */<br />wb.Close( false ) ; /* I don't want to save the newly added PublishObject */<br /><br />Isn't that cool!Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-812653388122713505.post-64161303309618479062008-05-13T19:53:00.000-07:002015-01-29T06:00:40.129-08:00Setting up registry to run .php scripts from command lineI wanted to have a script in php that I could run in the following way:<br />
<br />
c:\tmp> myscript.php argument1 "second argument"<br />
<br />
This is what I came up to:<br />
<br />
a) In the file explorer (not internet! file!) double click on your .php script, select the 'Select the program from a list', Browse to php.exe, mark 'always use the selected program to open this kind of file', and accept.<br />
<br />
This, will create a HKEY_CLASS_ROOT/.php entry with the value php_auto_file.<br />
It will also create the HKEY_CLASS_ROOT/php_auto_file/shell/open/command with the default entry: "c:\php\php.exe" "%1"<br />
(the path to the php.exe file depends on where you have installed php in!)<br />
<br />
This kind of registration will allow you now running your scripts from the command line but it WON'T allow you to pass any arguments.<br />
<br />
b) That's why you have to the HKEY_CLASS_ROOT/php_auto_file/shell/open/command entry to the following: "c:\php\php.exe" "%1" %*<br />
<br />
Here you go. Now you can prepare your myscript.php to look like this, and test the execution:<br />
print_r( $argv ) ;<br />
?><br />
<br />
myscript.php argument1 "second argument"<br />
<br />
Result:<br />
<br />
Array<br />
(<br />
[0] => c:\tmp\myscript.php<br />
[1] => argument1<br />
[2] => second argument<br />
)Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-812653388122713505.post-10419487673378366182008-05-02T17:16:00.000-07:002013-05-23T11:03:42.800-07:00poll: protocol failure in circuit setup (Linux)To tell the truth, I'm not sure it's the Linux issue only. It can be on other platforms as well.<br /><br />If you saw something like this in telnet/ssh:<br /><br />connect to address 1.2.3.4 port 544: Connection refused<br />Trying krb4 rsh...<br />connect to address 1.2.3.4 port 544: Connection refused<br />trying normal rsh (/usr/bin/rsh)<br />poll: protocol failure in circuit setup<br /><br />then what probably causes it is firewall (iptables)<br />The quicky method is simply to shutdown the iptables firewall:<br />> su -<br />> services iptables stop<br /><br />However, if you reboot your machine, the iptables will start and you will hit the problem again.<br /><br />To permanently shut down the firwall service then, do the following:<br />> su -<br />> chkconfig --list iptables<br /><br />- you will probably see this:<br />iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off<br /><br />- then do:<br />> chkconfig --level 345 iptables off<br />> chkconfig --list iptables<br /><br />- now you should see this:<br />iptables 0:off 1:off 2:on 3:off 4:off 5:off 6:off<br /><br />Of course, for the current session, you still will have to call service iptables stop, but I guess you already know it.Unknownnoreply@blogger.com6tag:blogger.com,1999:blog-812653388122713505.post-17688467883387468742008-04-09T21:13:00.000-07:002008-04-11T10:57:09.418-07:00Returning error code from a script in LinuxMost people moving to Linux are getting surprised by the fact that a simple operation "<strong>return 1</strong>" can cause an error:<br /><br />./a.sh: line 1: return: can only `return' from a function or sourced script<br /><br />Not all Linuxes return this problem, however, it's enough anoying if you want to keep the script for all the platforms.<br /><br />There is a simple solution for this, though!<br /><br /><pre><br /># $1 - error code<br />fun_return() {<br /> return $1<br />}<br /> <br />fun_return 1<br /> <br /></pre><br /><br />You can check this out by yourself. Write a sctipt with the above example, run it and check the value of $?Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-812653388122713505.post-14287028506692386772008-04-09T20:20:00.001-07:002008-04-11T10:51:07.184-07:00UNIX/Linux shell and returning values from functionsHere is an interesting fact.<br /><br />Let's assume you want to write a function <strong>myfun_initialize()</strong><br /><br />If the function is supposed to initialize some variables then <strong>DO NOT RETURN</strong> result of this function through the `function caller` (well, I have just made up this name.)<br /><br />In other words...<br /><br /><strong><u><span style="color:#33cc00;">right:</span></u></strong><br /><pre>myfun_initialize parameters<br />[ "$var_initialize" = "ok" ] {<br /> echo "Oops!"<br /> return<br />}</pre><br /><span style="color:#cc0000;"><strong><u>wrong:</u></strong></span><br /><pre>[ "`myfun_initialize parameters`" = "ok" ] {<br /> echo "Oops!"<br /> return<br />}<br /></pre><br /><br />Why is it wrong? I wish I had a simple explanation, but if the <strong>myfun_initialize</strong> function initializes some external variables you would like to use later on, then by calling <strong><span style="color:#cc0000;">`myfun_initialize`</span></strong> you will initialize temporary variables, and these outside of the call will be unchanged!<br /><br /><u>Test it yourself:</u><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfzA5Ud6y812-uKQ0DT_ppzbJNJbl0YahB51FWQ-eMdhOHXqXrifqfSgjsy6t2X1sJworJ847Hrd0fJ1uQBkg25_mZDH39y1WaL1pCdfM7Ky5K-y0_mp13gOqCMJZLaR2I5NcjdrPnB2US/s1600-h/example.jpg"><img id="BLOGGER_PHOTO_ID_5187456822815005746" style="CURSOR: hand" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfzA5Ud6y812-uKQ0DT_ppzbJNJbl0YahB51FWQ-eMdhOHXqXrifqfSgjsy6t2X1sJworJ847Hrd0fJ1uQBkg25_mZDH39y1WaL1pCdfM7Ky5K-y0_mp13gOqCMJZLaR2I5NcjdrPnB2US/s200/example.jpg" border="0" /></a><br /><br /><u>Here is the text</u><br /><pre><br />MYVAR="nothing"<br /> <br /># $1 - value<br />myfun() {<br /> MYVAR="$1"<br />}<br /> <br />echo "MYVAR before calling myfun is $MYVAR"<br />if [ "`myfun something`" = "" ]<br /> then<br /> echo "myfun returned an empty string"<br /> echo "MYVAR after calling \`myfun something \` is $MYVAR"<br /> else<br /> echo "myfun hasn't returned an empty string?!"<br /> echo "MYVAR after calling \`myfun something\` is $MYVAR"<br /> fi<br /> <br />myfun something<br />echo "MYVAR after calling myfun something is $MYVAR"<br /> <br /></pre><br /><br /><span style="font-family:arial;">So what is the solution?</span><br />Use a variable to return the result.<br />Example:<br /><br /><pre><br />myfunc() {<br /> ....<br /> var_myfunc="ok"<br />}<br /> <br />myfunc<br />[ "$myfunc" = "ok" ] && {<br /> ...<br />}<br /></pre>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-812653388122713505.post-6444373870460131372008-04-09T19:59:00.000-07:002008-05-23T21:44:51.814-07:00HP-UX - group permissions issueLet's assume that there is a guy user name <strong>paul</strong> who's main group is developer.<br />His home directory belongs to <strong>paul:developer</strong>.<br /><br />Now, let's assume my main group is <strong>users</strong>, and the <strong>developer</strong> group is my secondary one.<br /><br />You would expect, probably, that I could do <strong>cd ~paul</strong> if only paul's home directory had <strong>g+rx</strong> attribute, right?<br /><br />Well, on HP-UX (at least) it does not have to be like that. I don't know if this is by default or not but what I have found out on our HP-UX machine is that there are two files in the <strong>/etc</strong> dirtectory - <strong>group</strong>, and <strong>logingroups</strong>.<br /><br />For sure you know the /etc/<strong>group</strong> file!<br />I bet you might not see the /etc/<strong>logingroups</strong> file, though.<br /><br />Now, if you want to make HP-UX behaving like other machines, you can simply create a link:<br /><br />ln -s /etc/logingroups /etc/group<br /><br />After this change my user will be able to do <strong>cd ~paul</strong>.Unknownnoreply@blogger.com0