tag:blogger.com,1999:blog-196367302024-03-18T21:45:15.471-07:00Ana's LairAna Amanhttp://www.blogger.com/profile/13337221634712791800noreply@blogger.comBlogger195125tag:blogger.com,1999:blog-19636730.post-6504517143791290852018-08-12T01:07:00.002-07:002018-08-12T01:07:49.900-07:00problem with mplayer diacritics Though not as popular as it used to be, <b>mplayer</b> is very versatile and I like it.<br />
On a certain movie the .srt subtitle was displaying funny characters.<br />
First I added all needed languages in <b>Language Settings </b>and then went into <b>~/.mplayer/config</b>
where I commented the iso8859-1 line and added <b>utf-8</b>. All worked well.<br />
<br />
<i>#subcp = iso8859-1 </i><br />
<i>subcp=utf-8</i><br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhz9hyVvUahbIzi16D_Fx9H3rs5l0bOe3ZfJb6WxZB8gbqdz18pcgCftEKZrIrtO6qefdEBEj6Nuq2mf_ai9ZxdwQjvQ4cBlZIqbSsNaQRc8azja_bpZpjRqEamsItixRe-NusRdA/s1600/lang.png" imageanchor="1"><img border="0" data-original-height="47" data-original-width="616" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhz9hyVvUahbIzi16D_Fx9H3rs5l0bOe3ZfJb6WxZB8gbqdz18pcgCftEKZrIrtO6qefdEBEj6Nuq2mf_ai9ZxdwQjvQ4cBlZIqbSsNaQRc8azja_bpZpjRqEamsItixRe-NusRdA/s1600/lang.png" /></a><div class="blogger-post-footer"><a href="http://anaaman.blogspot.com">Ana's Lair</a></div>Ana Amanhttp://www.blogger.com/profile/13337221634712791800noreply@blogger.com0tag:blogger.com,1999:blog-19636730.post-28610086772596611282018-02-05T04:49:00.000-08:002018-02-05T04:49:14.342-08:00Schedule ETH transactions with ChronobotSometimes you need to make an <b>Ethereum payment</b> transfer at a <b>specific time</b> that may not be very convenient to you(middle of the night, airplane flight, etc). With <a href="https://chronobot.io">Ethereum Chronobot</a>, you can submit signed transactions to be executed lately at the time you choose. In the case of ICOs this might be very handy, because you can prepare everything and schedule the payment exactly when the ICO starts so you minimize the chances of missing it.
<br><br>
Chronobot will broadcast your transactions to multiple nodes so miners can pick it up very fast. There is no need to keep your internet connection up or wallet open, once you have submitted to Chronobot, everything will be done <b>automatically</b>.
<div class="blogger-post-footer"><a href="http://anaaman.blogspot.com">Ana's Lair</a></div>Ana Amanhttp://www.blogger.com/profile/13337221634712791800noreply@blogger.com0tag:blogger.com,1999:blog-19636730.post-11066214675807343352017-07-10T00:44:00.000-07:002017-07-10T00:44:00.770-07:00Best domains suggestion toolI've been searching lately for some free domain names and I've tried several tools.
<a href="http://www.leandomainsearch.com">leandomainsearch.com</a> has been the most helpful for common extensions such as .com/.net
For the new extensions and exotic extensions <a href="http://www.domainsbot.com">domainsbot.com</a> is ok.<div class="blogger-post-footer"><a href="http://anaaman.blogspot.com">Ana's Lair</a></div>Ana Amanhttp://www.blogger.com/profile/13337221634712791800noreply@blogger.com0tag:blogger.com,1999:blog-19636730.post-8261405926604572122017-05-24T11:16:00.000-07:002017-05-24T21:45:40.708-07:00unique and common names combosChecking again common first names on my surname: <a href="http://www.namesdir.net/s/aman">Aman</a> and first name <a href="http://www.namesdir.net/f/ana">Ana</a>, and found at least 17 people named Ana Aman. Amazing!<div class="blogger-post-footer"><a href="http://anaaman.blogspot.com">Ana's Lair</a></div>Ana Amanhttp://www.blogger.com/profile/13337221634712791800noreply@blogger.com0tag:blogger.com,1999:blog-19636730.post-50181854383407388632017-01-14T12:10:00.003-08:002017-01-14T12:15:27.145-08:00 unzip skipping: file.txt `PPMd' method not supportedIt seems like unzip does not support 7z, so to decompress such file I had to install p7zip:<br />
<br />
$ <b>apt-get install p7zip-full</b><br />
then<br />
$ <b>7z x file.zip</b><br />
<div class="blogger-post-footer"><a href="http://anaaman.blogspot.com">Ana's Lair</a></div>Ana Amanhttp://www.blogger.com/profile/13337221634712791800noreply@blogger.com0tag:blogger.com,1999:blog-19636730.post-9636990980598894872016-08-11T01:19:00.000-07:002016-08-11T01:19:04.034-07:00quickly replace spaces with underscore in bash<b>find -name "* *" -type f | rename 's/ /_/g'</b><div class="blogger-post-footer"><a href="http://anaaman.blogspot.com">Ana's Lair</a></div>Ana Amanhttp://www.blogger.com/profile/13337221634712791800noreply@blogger.com0tag:blogger.com,1999:blog-19636730.post-12184001400053356312016-06-03T22:23:00.000-07:002016-06-03T22:23:54.478-07:00transfer/copy database with SSH with only one command lineYou can migrate a database using a single command line:<br><br>
<b>mysqldump –add-drop-table –extended-insert –force –log-error=error.log -uUSER -pPASS OLD_DB_NAME | ssh -C user@newhost "mysql -uUSER -pPASS NEW_DB_NAME"</b>
<div class="blogger-post-footer"><a href="http://anaaman.blogspot.com">Ana's Lair</a></div>Ana Amanhttp://www.blogger.com/profile/13337221634712791800noreply@blogger.com0tag:blogger.com,1999:blog-19636730.post-29727983811534386972016-06-03T11:12:00.000-07:002016-06-03T11:13:03.083-07:00man: can't set the locale; make sure $LC_* and $LANG are correctI keep getting this error:<br>
<b>man: can't set the locale; make sure $LC_* and $LANG are correct</b><br><br>
I tried locale-gen and many other things, without success.<br>
The only thing that fixed it is: <b>export LC_ALL=en_US.UTF-8 </b> (which of course can be added in .profile to be permanent) <div class="blogger-post-footer"><a href="http://anaaman.blogspot.com">Ana's Lair</a></div>Ana Amanhttp://www.blogger.com/profile/13337221634712791800noreply@blogger.com0tag:blogger.com,1999:blog-19636730.post-76660713418361763442016-04-15T23:51:00.000-07:002016-04-15T23:51:34.402-07:00Search engine for html source code searchI needed to search for a little code which is available only in HTML source, not in the rendered page. So a simple search would show nothing. After reading on <a href="https://www.quora.com/Is-there-a-search-engine-that-can-search-source-code-of-websites">Quora</a> and <a href="http://stackoverflow.com/questions/4265748/search-in-html-source-with-google">Stackoverflow</a>, I've found some recommendations: MeanPath, Blekko, Datanyze, Nerdydata. Useless, except some limited results from Google, nothing really worked.
<div class="blogger-post-footer"><a href="http://anaaman.blogspot.com">Ana's Lair</a></div>Ana Amanhttp://www.blogger.com/profile/13337221634712791800noreply@blogger.com0tag:blogger.com,1999:blog-19636730.post-8360968928581493132016-04-15T00:59:00.001-07:002016-04-15T00:59:03.208-07:00Add Russian charset in Linuxmint/DebianI opened a console and tried to paste some Russian word but it looked very weird.
Then I run: <b># locale-gen ru_RU.UTF-8</b> and all works well.<div class="blogger-post-footer"><a href="http://anaaman.blogspot.com">Ana's Lair</a></div>Ana Amanhttp://www.blogger.com/profile/13337221634712791800noreply@blogger.com0tag:blogger.com,1999:blog-19636730.post-25725588040688503572016-04-08T00:12:00.001-07:002016-04-08T00:13:26.567-07:00Aman surnameSome more research on my name...<br>
<a href="http://es.namespedia.com/details/Aman">Aman</a> seems to be a popular surname in USA and also a popular first name in India. It means "peace" and rhymes with Atman and Batman.<div class="blogger-post-footer"><a href="http://anaaman.blogspot.com">Ana's Lair</a></div>Ana Amanhttp://www.blogger.com/profile/13337221634712791800noreply@blogger.com0tag:blogger.com,1999:blog-19636730.post-35302688312377157142016-04-01T06:04:00.000-07:002016-04-01T06:04:37.748-07:00Surname AmanToday I have taken a better look on Locate My Name website and I have found some interesting facts. I had no idea my name is so popular in these countries:
<a href="http://www.locatemyname.com/fr/Aman">/fr/Aman</a>
<a href="http://www.locatemyname.com/de/Aman">/de/Aman</a>
<a href="http://www.locatemyname.com/at/Aman">/at/Aman</a>.<div class="blogger-post-footer"><a href="http://anaaman.blogspot.com">Ana's Lair</a></div>Ana Amanhttp://www.blogger.com/profile/13337221634712791800noreply@blogger.com0tag:blogger.com,1999:blog-19636730.post-2968153871326408002016-03-28T04:01:00.000-07:002016-03-28T04:01:18.037-07:00Type accent marks, diacritics and other characters onlineIf you need quickly diacritics or currency signs, <a href="http://www.typeit.org/">typeit.org</a> does it for you. Many languages supported.<div class="blogger-post-footer"><a href="http://anaaman.blogspot.com">Ana's Lair</a></div>Ana Amanhttp://www.blogger.com/profile/13337221634712791800noreply@blogger.com0tag:blogger.com,1999:blog-19636730.post-39773954935080553942016-03-26T09:16:00.000-07:002016-03-26T09:16:05.600-07:00SSH port forwarding: bind: Cannot assign requested addressWhile trying to do a simple port forwarding to access a remote mysql server via a secured channel I was getting an annoying <b>bind: Cannot assign requested address</b>. <br>
<br>
$ ssh -v user@host.biz -L5555:localhost:3306<br>
debug1: Local forwarding listening on ::1 port 5555.<br>
bind: Cannot assign requested address<br>
<br>
So it must be the buggy IPv6, after adding -4, all worked like a charm.<br>
<br>
$ <b>ssh -4 -v user@host.biz -L5555:localhost:3306</b><br>
debug1: Local forwarding listening on 127.0.0.1 port 5555.<br>
debug1: channel 0: new [port listener]<br>
<div class="blogger-post-footer"><a href="http://anaaman.blogspot.com">Ana's Lair</a></div>Ana Amanhttp://www.blogger.com/profile/13337221634712791800noreply@blogger.com0tag:blogger.com,1999:blog-19636730.post-82921659778692583752016-03-26T04:12:00.001-07:002016-03-26T04:12:31.907-07:00Diacritics in a linux console for pico/nano/etcI wanted to quickly edit a text file with pico and when I pasted a word, I noticed that all diacritics were replaced with some funny characters. A quick fix was to edit /etc/locale.gen and add my language like <b>pl_PL.UTF-8 UTF-8</b> for Polish. Then run <b># locale-gen</b> as root and all was working good. A list with all supported languages can be found in /usr/share/i18n/SUPPORTED
<div class="blogger-post-footer"><a href="http://anaaman.blogspot.com">Ana's Lair</a></div>Ana Amanhttp://www.blogger.com/profile/13337221634712791800noreply@blogger.com0tag:blogger.com,1999:blog-19636730.post-70273868462092685972016-01-25T12:18:00.000-08:002016-01-25T12:18:28.676-08:00SCAM ALERT: Blue strawberries, climbing strawberries, blue roses<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQ4R9bXx5YgzlX7ziJgAhN_sfdgHgORONKuIAGAPTZc1f83U7Oo_yF9-0iaP-dV_UZM03njN7VFdQRmXY4f5dB8XojdKiAZR4amED3yKLHyUgVXcKHkomK7P019g5VvbcxNOtrmw/s1600/strawberry2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="252" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQ4R9bXx5YgzlX7ziJgAhN_sfdgHgORONKuIAGAPTZc1f83U7Oo_yF9-0iaP-dV_UZM03njN7VFdQRmXY4f5dB8XojdKiAZR4amED3yKLHyUgVXcKHkomK7P019g5VvbcxNOtrmw/s320/strawberry2.png" width="320" /></a></div>
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_DUCKHwEyR9PGImGjlZY2M-aZnk92KDIaRageFzICkryI1yBjQZDarjIJj0Zr5SnsRcqbyaP-vn9lVv7ca8DGmDX2lDq51Tv9IzdjcSuAJG3d4S2aMSstKtuDXd_AEzlx8M7ttA/s1600/amazon_review.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="216" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_DUCKHwEyR9PGImGjlZY2M-aZnk92KDIaRageFzICkryI1yBjQZDarjIJj0Zr5SnsRcqbyaP-vn9lVv7ca8DGmDX2lDq51Tv9IzdjcSuAJG3d4S2aMSstKtuDXd_AEzlx8M7ttA/s320/amazon_review.png" width="320" /></a>
<br />
<br />
A few weeks ago I have ordered from Ebay some strawberry seeds. I wanted to get as many varieties as possible and while searching I noticed some guys offer blue or violet or even green strawberry seeds. I ordered a couple of those too, only to find out later that such things don't even exist and the pictures are made in Photoshop. Then I looked at reviews and I realised how many people got scammed the same way. Many gave positive reviews right away after receiving the seeds. Shame on all these sellers for what they are doing. You spend money plus time and resources to take care of something that has no chances to succeed. Shame on them and shame on me because I researched this only after the purchase. This works very well with ebay feedback because getting a fruit from seeds could take years, and you can no longer leave feedbacks after 60 days so these sellers keep 99%+ positives and appear very legit.
<br><br>
<b>It's 100% SCAM</b>. If you look on youtube there is no single video of real blue or climbing strawberries. Yeah, videos can be manipulated too, but not as easy as an image.<div class="blogger-post-footer"><a href="http://anaaman.blogspot.com">Ana's Lair</a></div>Ana Amanhttp://www.blogger.com/profile/13337221634712791800noreply@blogger.com0tag:blogger.com,1999:blog-19636730.post-79019895608816472142015-11-30T00:32:00.001-08:002015-12-12T04:28:21.431-08:00Request exceeded the limit of 10 internal redirects due to probable configuration error.I upgraded to Apache 2.4.10 and I am getting these errors for sites which used to work: <br />
<br />
<i>AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.</i><br />
<br />
One strange thing is these happen only with <b>.htaccess</b> files. So if I use exactly the same configuration but written in vhosts config file such as <b>/etc/apache2/sites-enabled/000-default.conf </b>all works well. So yes, one quick fix is to put it there. But after doing some tests, I found out apache 2.4 does not like when you redirect stuff to index.php but you don't have a rule for index.php itsels. So simply keeping all rules and adding something like <b>RewriteRule ^index\.php$ - [L]</b> fixed the problem.<br />
<br />
[UPDATE] On many other cases it seems to work without any trouble or extra rule, but on that particular one not... strange. <div class="blogger-post-footer"><a href="http://anaaman.blogspot.com">Ana's Lair</a></div>Ana Amanhttp://www.blogger.com/profile/13337221634712791800noreply@blogger.com0tag:blogger.com,1999:blog-19636730.post-55195560104723397902015-11-29T06:11:00.002-08:002015-11-30T00:33:03.877-08:00kernel: do_IRQ: No irq handler for vector (irq -1)On a fresh Debian Jessie I kept getting every couple of minutes this error:<br />
<i>do_IRQ: No irq handler for vector (irq -1)</i><br />
A suggested solution is to add "<b>pci=nomsi,noaer</b>" in <b>/etc/default/grub</b> at GRUB_CMDLINE_LINUX<br />
However, <i>noaer </i>refers to PCIE Advanced Error Reporting and I don't want only to hide the mess, I want to fix it (if possible).<br />
Only adding <i><b>pci=nomsi</b> </i>seems to do the trick so far.<br />
Also don't forget to do a update-grub after you edit /etc/default/grub.<div class="blogger-post-footer"><a href="http://anaaman.blogspot.com">Ana's Lair</a></div>Ana Amanhttp://www.blogger.com/profile/13337221634712791800noreply@blogger.com0tag:blogger.com,1999:blog-19636730.post-73404918152231149332015-11-28T06:40:00.000-08:002015-11-28T06:40:55.618-08:00Debian 8 does not execute /etc/rc.localI have just installed a fresh Debian 8 Jessie and then I put something in /etc/rc.local.<br>
To my suprise, after the reboot, the command did not execute.<br>
Log investigation showed:
<br>
<blockquote><i>
Failed to start /etc/rc.local Compatibility.<br>
Failed at step EXEC spawning /etc/rc.local: Exec format error</i></blockquote>
So I simply added "#!/bin/sh -e" in the first line of rc.local and then it worked well.<div class="blogger-post-footer"><a href="http://anaaman.blogspot.com">Ana's Lair</a></div>Ana Amanhttp://www.blogger.com/profile/13337221634712791800noreply@blogger.com0tag:blogger.com,1999:blog-19636730.post-19689067965103652312015-11-19T04:19:00.002-08:002015-11-28T06:34:54.921-08:00Youtube mp3 extract in Debian Linuxyoutube-dl --extract-audio --audio-format mp3 [URL]<div class="blogger-post-footer"><a href="http://anaaman.blogspot.com">Ana's Lair</a></div>Ana Amanhttp://www.blogger.com/profile/13337221634712791800noreply@blogger.com0tag:blogger.com,1999:blog-19636730.post-89391348632466917772015-10-19T06:38:00.001-07:002015-10-19T06:38:27.565-07:00HITACHi Air Conditioner green light turn offSince last year I have a HITACHI Air Conditioner and the technician told me to clean the filters every two weeks, but he didn't mention anything about the green led. So after a while, this green light turned on, I noticed it has something to do with the filters so I have cleaned them hoping it has some sensor and will turn off automatically. But it didn't. Later I found you have to press the AUTO SWING from the remote while the unit is off. And after 200 hours of functioning it will turn on again to remind you about cleaning the filters.<div class="blogger-post-footer"><a href="http://anaaman.blogspot.com">Ana's Lair</a></div>Ana Amanhttp://www.blogger.com/profile/13337221634712791800noreply@blogger.com0tag:blogger.com,1999:blog-19636730.post-37195632329835440952015-10-19T06:33:00.001-07:002015-10-19T06:33:40.910-07:00Pasting source code in friendly formatHere are three tools you can use to paste source codes:
<br><br>
<a href="http://codeformatter.blogspot.de/">http://codeformatter.blogspot.de</a><br>
<a href="http://hilite.me/">http://hilite.me/</a><br>
<a href="http://markup.su/highlighter/">http://markup.su/highlighter/</a>
<div class="blogger-post-footer"><a href="http://anaaman.blogspot.com">Ana's Lair</a></div>Ana Amanhttp://www.blogger.com/profile/13337221634712791800noreply@blogger.com0tag:blogger.com,1999:blog-19636730.post-88738462652392394972015-10-06T09:02:00.001-07:002015-10-06T09:02:54.297-07:00Mass kill processes in MySQL "show processlist"So your server load is high you did "SHOW PROCESSLIST;" and you noticed many slow queries and you want to kill them. <br />
If the list is too long to do it manually, you may want to try this way:<br />
<br />
<div style="background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #557799;"><?php</span>
<span style="color: #008800; font-weight: bold;">include</span>(<span style="background-color: #fff0f0;">"mySqlClass.inc.php"</span>);
<span style="color: #996633;">$serv</span><span style="color: #333333;">=</span><span style="background-color: #fff0f0;">"localhost"</span>;
<span style="color: #996633;">$user</span><span style="color: #333333;">=</span><span style="background-color: #fff0f0;">"root"</span>;
<span style="color: #996633;">$pass</span><span style="color: #333333;">=</span><span style="background-color: #fff0f0;">"YOUR_PASS"</span>;
<span style="color: #996633;">$database</span><span style="color: #333333;">=</span><span style="background-color: #fff0f0;">"SOME_DB"</span>;
<span style="color: #996633;">$link</span> <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> mySqlClass();
<span style="color: #996633;">$link</span><span style="color: #333333;">-></span><span style="color: #0000cc;">Connect</span>(<span style="color: #996633;">$serv</span>,<span style="color: #996633;">$user</span>,<span style="color: #996633;">$pass</span>,<span style="color: #996633;">$database</span>);
<span style="color: #996633;">$result</span><span style="color: #333333;">=</span><span style="color: #996633;">$link</span><span style="color: #333333;">-></span><span style="color: #0000cc;">SqlQuery</span>(<span style="background-color: #fff0f0;">"SHOW FULL PROCESSLIST"</span>);
<span style="color: #008800; font-weight: bold;">while</span> (<span style="color: #996633;">$result</span><span style="color: #333333;">-></span><span style="color: #0000cc;">NextRow</span>()) {
<span style="color: #996633;">$process_id</span><span style="color: #333333;">=</span><span style="color: #996633;">$result</span><span style="color: #333333;">-></span><span style="color: #0000cc;">field</span>[<span style="background-color: #fff0f0;">"Id"</span>];
<span style="color: #008800; font-weight: bold;">if</span> (<span style="color: #996633;">$result</span><span style="color: #333333;">-></span><span style="color: #0000cc;">field</span>[<span style="background-color: #fff0f0;">"Time"</span>]<span style="color: #333333;">></span><span style="color: #0000dd; font-weight: bold;">200</span>) <span style="color: #996633;">$link</span><span style="color: #333333;">-></span><span style="color: #0000cc;">SqlQuery</span>(<span style="background-color: #fff0f0;">"KILL </span><span style="background-color: #eeeeee;">$process_id</span><span style="background-color: #fff0f0;">"</span>);
}
<span style="color: #557799;">?></span>
</pre>
</div>
<br><br>
and the mySqlClass.inc.php:
<br><br>
<!-- HTML generated using hilite.me --><br />
<div style="background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #557799;"><?php</span>
<span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">mySqlClass</span> {
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #996633;">$query_count</span>;
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #996633;">$query_time</span>;
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #996633;">$database</span>;
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #996633;">$link</span>;
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #996633;">$db_connected</span>;
<span style="color: #008800; font-weight: bold;">function</span> <span style="color: #0066bb; font-weight: bold;">__construct</span>()
{
<span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">query_count</span> <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span>;
<span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">query_time</span> <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span>;
}
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">function</span> <span style="color: #0066bb; font-weight: bold;">Connect</span>(<span style="color: #996633;">$host</span>, <span style="color: #996633;">$user</span>, <span style="color: #996633;">$password</span>, <span style="color: #996633;">$database</span>)
{
<span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">database</span> <span style="color: #333333;">=</span> <span style="color: #996633;">$database</span>;
<span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">link</span> <span style="color: #333333;">=</span> <span style="color: #333333;">@</span><span style="color: #007020;">mysql_connect</span>(<span style="color: #996633;">$host</span>, <span style="color: #996633;">$user</span>, <span style="color: #996633;">$password</span>, <span style="color: #008800; font-weight: bold;">true</span>);
<span style="color: #008800; font-weight: bold;">if</span> (<span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">link</span>)
{
<span style="color: #008800; font-weight: bold;">if</span> (<span style="color: #333333;">@</span><span style="color: #007020;">mysql_select_db</span>(<span style="color: #996633;">$database</span>, <span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">link</span>))
{
<span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">db_connected</span> <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">true</span>;
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #008800; font-weight: bold;">true</span>;
}
}
<span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">_error</span>(<span style="color: #007020;">mysql_errno</span>(), <span style="color: #007020;">mysql_error</span>());
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #008800; font-weight: bold;">false</span>;
}
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">function</span> <span style="color: #0066bb; font-weight: bold;">SqlQuery</span>(<span style="color: #996633;">$sql</span>)
{
<span style="color: #996633;">$time_start</span> <span style="color: #333333;">=</span> <span style="color: #007020;">explode</span>(<span style="background-color: #fff0f0;">' '</span>, <span style="color: #007020;">microtime</span>());
<span style="color: #008800; font-weight: bold;">if</span> (<span style="color: #333333;">!</span><span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">db_connected</span>) <span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">_error</span>(<span style="color: #0000dd; font-weight: bold;">0</span>, <span style="background-color: #fff0f0;">'Error: MySQL DB Not Connected'</span>);
<span style="color: #996633;">$result_resource</span> <span style="color: #333333;">=</span> <span style="color: #333333;">@</span><span style="color: #007020;">mysql_query</span>(<span style="color: #996633;">$sql</span>, <span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">link</span>);
<span style="color: #008800; font-weight: bold;">if</span> (<span style="color: #333333;">!</span><span style="color: #996633;">$result_resource</span>) <span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">_error</span>(<span style="color: #333333;">@</span><span style="color: #007020;">mysql_errno</span>(<span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">link</span>), <span style="color: #333333;">@</span><span style="color: #007020;">mysql_error</span>(<span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">link</span>));
<span style="color: #996633;">$obj</span> <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> SqlQueryResult(<span style="color: #996633;">$result_resource</span>);
<span style="color: #008800; font-weight: bold;">if</span> (<span style="color: #996633;">$obj</span><span style="color: #333333;">-></span><span style="color: #0000cc;">RowCount</span>() <span style="color: #333333;">></span> <span style="color: #0000dd; font-weight: bold;">0</span>)
{
<span style="color: #888888;">// Return the first row of data results</span>
<span style="color: #996633;">$result_array</span> <span style="color: #333333;">=</span> <span style="color: #333333;">@</span><span style="color: #007020;">mysql_fetch_array</span>(<span style="color: #996633;">$result_resource</span>, MYSQL_ASSOC);
<span style="color: #008800; font-weight: bold;">if</span> (<span style="color: #996633;">$result_array</span>)
{
<span style="color: #008800; font-weight: bold;">while</span> (<span style="color: #008800; font-weight: bold;">list</span>(<span style="color: #996633;">$key</span>, <span style="color: #996633;">$value</span>) <span style="color: #333333;">=</span> <span style="color: #007020;">each</span>(<span style="color: #996633;">$result_array</span>))
{
<span style="color: #996633;">$obj</span><span style="color: #333333;">-></span><span style="color: #0000cc;">field</span>[<span style="color: #996633;">$key</span>] <span style="color: #333333;">=</span> <span style="color: #996633;">$value</span>;
}
}
}
<span style="color: #996633;">$time_end</span> <span style="color: #333333;">=</span> <span style="color: #007020;">explode</span> (<span style="background-color: #fff0f0;">' '</span>, <span style="color: #007020;">microtime</span>());
<span style="color: #996633;">$query_time</span> <span style="color: #333333;">=</span> <span style="color: #996633;">$time_end</span>[<span style="color: #0000dd; font-weight: bold;">1</span>]<span style="color: #333333;">+</span><span style="color: #996633;">$time_end</span>[<span style="color: #0000dd; font-weight: bold;">0</span>]<span style="color: #333333;">-</span><span style="color: #996633;">$time_start</span>[<span style="color: #0000dd; font-weight: bold;">1</span>]<span style="color: #333333;">-</span><span style="color: #996633;">$time_start</span>[<span style="color: #0000dd; font-weight: bold;">0</span>];
<span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">query_time</span> <span style="color: #333333;">+=</span> <span style="color: #996633;">$time_end</span>[<span style="color: #0000dd; font-weight: bold;">1</span>] <span style="color: #333333;">+</span> <span style="color: #996633;">$time_end</span>[<span style="color: #0000dd; font-weight: bold;">0</span>] <span style="color: #333333;">-</span> <span style="color: #996633;">$time_start</span>[<span style="color: #0000dd; font-weight: bold;">1</span>] <span style="color: #333333;">-</span> <span style="color: #996633;">$time_start</span>[<span style="color: #0000dd; font-weight: bold;">0</span>];
<span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">query_count</span><span style="color: #333333;">++</span>;
<span style="color: #008800; font-weight: bold;">return</span>(<span style="color: #996633;">$obj</span>);
}
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">function</span> <span style="color: #0066bb; font-weight: bold;">QueryCount</span>()
{
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">query_count</span>;
}
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">function</span> <span style="color: #0066bb; font-weight: bold;">QueryTime</span>()
{
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">query_time</span>;
}
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #008800; font-weight: bold;">function</span> <span style="color: #0066bb; font-weight: bold;">_error</span>(<span style="color: #996633;">$error_number</span>, <span style="color: #996633;">$error_text</span>)
{
<span style="color: #008800; font-weight: bold;">if</span> (<span style="color: #996633;">$error_number</span> <span style="color: #333333;">!=</span> <span style="color: #0000dd; font-weight: bold;">1141</span>)
{
<span style="color: #008800; font-weight: bold;">echo</span> <span style="background-color: #fff0f0;">"Error #</span><span style="background-color: #eeeeee;">$error_number</span><span style="background-color: #fff0f0;">: </span><span style="background-color: #eeeeee;">$error_text</span><span style="background-color: #fff0f0;">"</span>;
<span style="color: #008800; font-weight: bold;">die</span>();
}
}
}
<span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">SqlQueryResult</span> {
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #996633;">$field</span>;
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #996633;">$result_resource</span>;
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #996633;">$num_rows</span>;
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #996633;">$current_row</span>;
<span style="color: #008800; font-weight: bold;">function</span> <span style="color: #0066bb; font-weight: bold;">__construct</span>(<span style="color: #996633;">$result_resource</span>)
{
<span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">result_resource</span> <span style="color: #333333;">=</span> <span style="color: #996633;">$result_resource</span>;
<span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">current_row</span> <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span>;
<span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">num_rows</span> <span style="color: #333333;">=</span> <span style="color: #333333;">@</span><span style="color: #007020;">mysql_num_rows</span>(<span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">result_resource</span>);
<span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">field</span> <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">array</span>();
}
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">function</span> <span style="color: #0066bb; font-weight: bold;">NextRow</span>()
{
<span style="color: #008800; font-weight: bold;">if</span> (<span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">current_row</span> <span style="color: #333333;">===</span> <span style="color: #0000dd; font-weight: bold;">0</span>)
{
<span style="color: #888888;">// Row already fetched from SqlQuery() function</span>
<span style="color: #888888;">// Do nothing</span>
}
<span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> (<span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">num_rows</span> <span style="color: #333333;">></span> <span style="color: #0000dd; font-weight: bold;">0</span> <span style="color: #008800; font-weight: bold;">AND</span> <span style="color: #996633;">$result_array</span> <span style="color: #333333;">=</span> <span style="color: #333333;">@</span><span style="color: #007020;">mysql_fetch_array</span>(<span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">result_resource</span>, MYSQL_ASSOC))
{
<span style="color: #888888;">// This is the next iteration and there is a counted row returned</span>
<span style="color: #888888;">// Grab data array</span>
<span style="color: #008800; font-weight: bold;">if</span> (<span style="color: #996633;">$result_array</span>)
{
<span style="color: #008800; font-weight: bold;">while</span> (<span style="color: #008800; font-weight: bold;">list</span>(<span style="color: #996633;">$key</span>, <span style="color: #996633;">$value</span>) <span style="color: #333333;">=</span> <span style="color: #007020;">each</span>(<span style="color: #996633;">$result_array</span>))
{
<span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">field</span>[<span style="color: #996633;">$key</span>] <span style="color: #333333;">=</span> <span style="color: #996633;">$value</span>;
}
}
}
<span style="color: #008800; font-weight: bold;">else</span>
{
<span style="color: #888888;">// No more rows, end of data iteration</span>
<span style="color: #888888;">// End result</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #008800; font-weight: bold;">false</span>;
}
<span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">current_row</span><span style="color: #333333;">++</span>;
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #008800; font-weight: bold;">true</span>;
}
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">function</span> <span style="color: #0066bb; font-weight: bold;">RowCount</span>()
{
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #996633;">$this</span><span style="color: #333333;">-></span><span style="color: #0000cc;">num_rows</span>;
}
}
</pre>
</div>
<div class="blogger-post-footer"><a href="http://anaaman.blogspot.com">Ana's Lair</a></div>Ana Amanhttp://www.blogger.com/profile/13337221634712791800noreply@blogger.com0tag:blogger.com,1999:blog-19636730.post-63397182218551384252015-09-27T03:20:00.003-07:002015-09-27T03:20:55.188-07:00Anagram and Rhyme GeneratorI had some fun today with <a href="http://www.namesgenerator.org/anagram-generator">Anagram Generator</a> and <a href="http://www.namesgenerator.org/rhyme-generator">Rhyme Generator</a>. For those who are unfamiliar with these, anagrams are rearrangements of the letters in a word. And of course, the rhyme tool is very useful if you want to do poetry.<div class="blogger-post-footer"><a href="http://anaaman.blogspot.com">Ana's Lair</a></div>Ana Amanhttp://www.blogger.com/profile/13337221634712791800noreply@blogger.com0tag:blogger.com,1999:blog-19636730.post-47455350135940077822015-09-26T00:47:00.000-07:002015-09-26T00:47:56.524-07:00Allow PHP in Posts and preg_match<a href="http://www.hitreach.co.uk/wordpress-plugins/allow-php-in-posts-and-pages/">Allow PHP in Posts</a> is a very cool plugin when you need to execute PHP in your posts, but you need a little time to get used to it, because it is kind of tricky. For instance I did not manage to use the preg_match function with square brackets. It simply replaces [a-z] with <a-z>. The only fix I could find is to use Code Snippets and add all the preg_match parts there, then use Shortcodes like [php function=5].
<br><br>
Also don't forget about [PHP debug=1] option which can be really useful.<div class="blogger-post-footer"><a href="http://anaaman.blogspot.com">Ana's Lair</a></div>Ana Amanhttp://www.blogger.com/profile/13337221634712791800noreply@blogger.com0