Subscribe: Ana's Lair
http://anaaman.blogspot.com/atom.xml
Added By: Feedage Forager Feedage Grade B rated
Language: English
Tags:
ana lair  ana  array  error  function  lair  mysql  public  query  resource  result array  result resource  result  time  user 
Rate this Feed
Rating: 3.3 starRating: 3.3 starRating: 3.3 starRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: Ana's Lair

Ana's Lair





Updated: 2016-09-21T04:58:57.713-07:00

 



quickly replace spaces with underscore in bash

2016-08-11T01:19:04.034-07:00

find -name "* *" -type f | rename 's/ /_/g'



transfer/copy database with SSH with only one command line

2016-06-03T22:23:54.478-07:00

You can migrate a database using a single command line:

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"



man: can't set the locale; make sure $LC_* and $LANG are correct

2016-06-03T11:13:03.083-07:00

I keep getting this error:
man: can't set the locale; make sure $LC_* and $LANG are correct

I tried locale-gen and many other things, without success.
The only thing that fixed it is: export LC_ALL=en_US.UTF-8 (which of course can be added in .profile to be permanent)



Search engine for html source code search

2016-04-15T23:51:34.402-07:00

I 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 Quora and Stackoverflow, I've found some recommendations: MeanPath, Blekko, Datanyze, Nerdydata. Useless, except some limited results from Google, nothing really worked.



Add Russian charset in Linuxmint/Debian

2016-04-15T00:59:03.208-07:00

I opened a console and tried to paste some Russian word but it looked very weird. Then I run: # locale-gen ru_RU.UTF-8 and all works well.



Aman surname

2016-04-08T00:13:26.567-07:00

Some more research on my name...
Aman 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.



Surname Aman

2016-04-01T06:04:37.748-07:00

Today 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: /fr/Aman/de/Aman/at/Aman.



Type accent marks, diacritics and other characters online

2016-03-28T04:01:18.037-07:00

If you need quickly diacritics or currency signs, typeit.org does it for you. Many languages supported.



SSH port forwarding: bind: Cannot assign requested address

2016-03-26T09:16:05.600-07:00

While trying to do a simple port forwarding to access a remote mysql server via a secured channel I was getting an annoying bind: Cannot assign requested address.

$ ssh -v user@host.biz -L5555:localhost:3306
debug1: Local forwarding listening on ::1 port 5555.
bind: Cannot assign requested address

So it must be the buggy IPv6, after adding -4, all worked like a charm.

$ ssh -4 -v user@host.biz -L5555:localhost:3306
debug1: Local forwarding listening on 127.0.0.1 port 5555.
debug1: channel 0: new [port listener]



Diacritics in a linux console for pico/nano/etc

2016-03-26T04:12:31.907-07:00

I 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 pl_PL.UTF-8 UTF-8 for Polish. Then run # locale-gen as root and all was working good. A list with all supported languages can be found in /usr/share/i18n/SUPPORTED



SCAM ALERT: Blue strawberries, climbing strawberries, blue roses

2016-01-25T12:18:28.676-08:00


(image)

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.

It's 100% SCAM. 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.



Request exceeded the limit of 10 internal redirects due to probable configuration error.

2015-12-12T04:28:21.431-08:00

I upgraded to Apache 2.4.10 and I am getting these errors for sites which used to work:

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.

One strange thing is these happen only with .htaccess files. So if I use exactly the same configuration but written in vhosts config file such as /etc/apache2/sites-enabled/000-default.conf 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 RewriteRule ^index\.php$ - [L] fixed the problem.

[UPDATE] On many other cases it seems to work without any trouble or extra rule, but on that particular one not... strange.



kernel: do_IRQ: No irq handler for vector (irq -1)

2015-11-30T00:33:03.877-08:00

On a fresh Debian Jessie I kept getting every couple of minutes this error:
do_IRQ: No irq handler for vector (irq -1)
A suggested solution is to add "pci=nomsi,noaer" in /etc/default/grub at GRUB_CMDLINE_LINUX
However,  noaer refers to PCIE Advanced Error Reporting and I don't want only to hide the mess, I want to fix it (if possible).
Only adding pci=nomsi seems to do the trick so far.
Also don't forget to do a update-grub after you edit /etc/default/grub.



Debian 8 does not execute /etc/rc.local

2015-11-28T06:40:55.618-08:00

I have just installed a fresh Debian 8 Jessie and then I put something in /etc/rc.local.
To my suprise, after the reboot, the command did not execute.
Log investigation showed:
Failed to start /etc/rc.local Compatibility.
Failed at step EXEC spawning /etc/rc.local: Exec format error
So I simply added "#!/bin/sh -e" in the first line of rc.local and then it worked well.



Youtube mp3 extract in Debian Linux

2015-11-28T06:34:54.921-08:00

youtube-dl --extract-audio --audio-format mp3 [URL]



Gender Checker

2015-10-20T01:10:07.760-07:00

I was often unsure if a name is male or female, but I have found this http://www.namesgenerator.org/check-name-gender-tool which works pretty well:

According to meaningofname.org gender for Sisi is Girl
According to namespedia.com gender for Sisi is 76% feminine, 24% masculine.



HITACHi Air Conditioner green light turn off

2015-10-19T06:38:27.565-07:00

Since 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.



Pasting source code in friendly format

2015-10-19T06:33:40.910-07:00

Here are three tools you can use to paste source codes:

http://codeformatter.blogspot.de
http://hilite.me/
http://markup.su/highlighter/



Mass kill processes in MySQL "show processlist"

2015-10-06T09:02:54.297-07:00

So your server load is high you did "SHOW PROCESSLIST;" and you noticed many slow queries and you want to kill them. If the list is too long to do it manually, you may want to try this way:Connect($serv,$user,$pass,$database);$result=$link->SqlQuery("SHOW FULL PROCESSLIST");while ($result->NextRow()) { $process_id=$result->field["Id"]; if ($result->field["Time"]>200) $link->SqlQuery("KILL $process_id");} ?>and the mySqlClass.inc.php: query_count = 0; $this->query_time = 0; } public function Connect($host, $user, $password, $database) { $this->database = $database; $this->link = @mysql_connect($host, $user, $password, true); if ($this->link) { if (@mysql_select_db($database, $this->link)) { $this->db_connected = true; return true; } } $this->_error(mysql_errno(), mysql_error()); return false; } public function SqlQuery($sql) { $time_start = explode(' ', microtime()); if (!$this->db_connected) $this->_error(0, 'Error: MySQL DB Not Connected'); $result_resource = @mysql_query($sql, $this->link); if (!$result_resource) $this->_error(@mysql_errno($this->link), @mysql_error($this->link)); $obj = new SqlQueryResult($result_resource); if ($obj->RowCount() > 0) { // Return the first row of data results $result_array = @mysql_fetch_array($result_resource, MYSQL_ASSOC); if ($result_array) { while (list($key, $value) = each($result_array)) { $obj->field[$key] = $value; } } } $time_end = explode (' ', microtime()); $query_time = $time_end[1]+$time_end[0]-$time_start[1]-$time_start[0]; $this->query_time += $time_end[1] + $time_end[0] - $time_start[1] - $time_start[0]; $this->query_count++; return($obj); } public function QueryCount() { return $this->query_count; } public function QueryTime() { return $this->query_time; } private function _error($error_number, $error_text) { if ($error_number != 1141) { echo "Error #$error_number: $error_text"; die(); } }}class SqlQueryResult { public $field; private $result_resource; private $num_rows; private $current_row; function __construct($result_resource) { $this->result_resource = $result_resource; $this->current_row = 0; $this->num_rows = @mysql_num_rows($this->result_resource); $this->field = array(); } public function NextRow() { if ($this->current_row === 0) { // Row already fetched from SqlQuery() function // Do nothing } else if ($this->num_rows > 0 AND $result_array = @mysql_fetch_array($this->result_resource, MYSQL_ASSOC)) { // This is the next iteration and there is a counted row returned // Grab data array if ($result_array) { while (list($key, $value) = each($result_array)) { $this->field[$key] = $value; } } } else { // No more rows, end of data iteration // End result return false; } $this->current_row++; return true; } public function RowCount() { return $this->num_rows; }}Ana's Lair[...]



Anagram and Rhyme Generator

2015-09-27T03:20:55.188-07:00

I had some fun today with Anagram Generator and Rhyme Generator. 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.



Allow PHP in Posts and preg_match

2015-09-26T00:47:56.524-07:00

Allow PHP in Posts 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].

Also don't forget about [PHP debug=1] option which can be really useful.



remove accents and diacritics from a string in PHP

2015-09-21T04:09:56.790-07:00

I needed to remove some diacritics from a text and the easiest way I've found is this:
$newstring = iconv('UTF-8', 'US-ASCII//TRANSLIT', $original_string);



EU ruins the beauty of Internet with cookie control and data protection

2015-08-24T23:04:13.168-07:00

Some EU laws are getting ridiculous. Look how many websites have this stupid cookie warning, but only the legitimate ones, the bad guys don't give a f* about this. And the data protection directive is so vague that it will only serve for abusive actions.



WPMU: You do not have sufficient permissions to access this page.

2015-08-21T02:46:05.062-07:00

While moving, a blog from WPMU to a single wordpress, I kept getting this message: "You do not have sufficient permissions to access this page."I have played for about an hour with wp_usermeta and wp_users. Tested all kinds of settings in wp_capabilities and wp_user_level but still nothing worked. Then I have spotted it in wp_options. The option_name wp_user_roles was missing and instead was something like wp_123_user_roles. After I renamed it, all worked like a charm.



your personal website archive

2015-07-26T00:19:40.287-07:00

While archive.org is the biggest online website archive - you have no control over it. If you want something that archives on command, you can use archive.is . It takes a "snapshot" of a webpage that will always be online even if the original page disappears. You can use it for your own sites or for other sites you like visiting. This way, you'll be able to see them even if they turn off or get suspended.