Install R language in CentOs Linux

2014/03/10 Leave a comment

Let’s see how to install R language in CentOs Linux. It is pretty simple:

Trying just that didn’t work…:

yum install R
No package R available.

And this one neither did:

yum install R-core R-devel
No pack…

# Install epel for El6 or CentOS 6
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
yum install R

Ok. Now R is already intelled. Let’s check it out:

R

R version 3.0.2 (2013-09-25) — “Frisbee Sailing”
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-redhat-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type ‘license()’ or ‘licence()’ for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type ‘contributors()’ for more information and
‘citation()’ on how to cite R or R packages in publications.

Type ‘demo()’ for some demos, ‘help()’ for on-line help, or
‘help.start()’ for an HTML browser interface to help.
Type ‘q()’ to quit R.

> a=(1)
> a
[1] 1
> ls()
[1] “a”
> a
[1] 1
> b=(1:9)
> b
[1] 1 2 3 4 5 6 7 8 9
> a+b
[1] 2 3 4 5 6 7 8 9 10
> sum(a)
[1] 1
> sum(b)
[1] 45
> mean(b)
[1] 5
> var(b)
[1] 7.5
> b^2
[1] 1 4 9 16 25 36 49 64 81

 

It works!

Categories: Snippets of Code Tags: , , , , ,

jQuery: uncaught typeError object has no method [How to fix]

2014/03/08 Leave a comment

If you are getting the following error while execution your jQuery code:

jQuery: uncaught typeError object [object Object] has no method ‘…’

Here it is how I fixed it. Very simple, just adding 1 line of code (the second one):


<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.4/jquery-ui.min.js"></script>
<script type="text/javascript" language="JavaScript">

… my jQuery code …

</script>

I hope it helps …

MySql add index alter table example

2014/03/04 Leave a comment

Syntax: ALTER TABLE mytable ADD INDEX idx_a_b (a, b);

This MySQL command will create a very useful combined index for this table:

CREATE TABLE IF NOT EXISTS mytable (
id INT(32) UNSIGNED NOT NULL AUTO_INCREMENT,
a INT(32) UNSIGNED NOT NULL,
b INT(32) UNSIGNED NOT NULL,
PRIMARY KEY (id)
);

Using that index, this kind of queries will run faster:

SELECT b FROM mytable WHERE a=’value’;

Because data scan is avoided, thanks to index usage.

List of best search engines in the world

2014/02/25 Leave a comment

Here it is a list of the best search engines in the world, the number of visits they get every day, the estimated value of the search engine and the sale price (US$) in case of acquisition:

google
	visits: 1 B
	funding: 25 M$
	value: 9 B$ (market cap: 410 B$)
	servers: 1 M
	pages: 100 B

yahoo!
	visits: 255 M
	funding: 7 M$
	value: 2 B$ (market cap: 39 B$)
	servers: 100 K

baidu (China)
	visits: 200 M
	funding: 161 M$
	value: 2 B$ (market cap: 60 B$)

yandex (Russia)
	visits: 60 M
	funding: 5 M$
	value: 500 M$ (market cap: 12 B$)

msn + bing
	visits: 44 M
	funding: ???
	value: 385 M$
	servers: 300 K

ask
	visits: 30 M
	funding: 25 M$
	value: 250 M$

powerset (ACQUIRED)
	visits: ???
	funding: 14.5 M$
	value: 13 M$
	acquired: 100M$

alltheweb (ACQUIRED)
	visits: ???
	funding: ???
	value: ???
	acquired: 100M$

duckduckgo
	visits: 1.5 M
	funding: 3 M$
	value: 13 M$
	servers: 10 K
	pages: 1B

dogpile
	visits: 450,000
	funding: ???
	value: 4 M$

blekko
	visits: 200,000
	funding: 59 M$
	value: 2 M$

ixquick
	visits: 160,000
	funding: ???
	value: 1.5 M$

excite
	visits: 150,000
	funding: ???
	value: 1.2 M$

gigablast
	visits: 80,000
	funding: ???
	value: 700 K$

hispavista (Spain)
	visits: 40,000
	funding: ???
	value: 350 K$

yippy + clusty
	visits: 27,000
	funding: 2 M$
	value: 230 K$

cdnpal
	visits: 25,000
	funding: ???
	value: 200 K$

hotbot
	visits: 17,000
	funding: ???
	value: 152 K$

teoma
	visits: 12,000
	funding: ???
	value: 100 K$
	acquired: 4M$

hakia
	visits: 3,000
	funding: 23 M$
	value: 16 K$

faroo
	visits: 2,500
	funding: ???
	value: 16 K$

Did I forget someone?

JSON_ERROR_SYNTAX while decoding huge json-encoded array

2014/02/21 2 comments

It took me a lot of time to eventually find out what was throwing the JSON error known as “JSON_ERROR_SYNTAX”. I was dealing with a huge array, more than 100,000 entries and 2MB in size. The PHP script processing the data always hangs when trying to decode the big array into a PHP variable. Using PHP function json_last_error() I could find out that JSON decoder was throwing the error code 4, meaning there was a syntax error in the json string.

http://php.net/function.json_last_error

Finally I found the array entry that makes JSON go crazy:

{...
,"laptops":"26"
,null:"26"
,"cad":"26"
,...}

NULL. Yes. That’s the culprit. So, bottom line: avoid array null keys at all cost.

Here is the code I used to locate the error:


<?php
	function json_error() {
		switch(json_last_error()) {
			case JSON_ERROR_NONE:
				return '';
			break;
			case JSON_ERROR_DEPTH:
				return 'JSON_ERROR_DEPTH';
			break;
			case JSON_ERROR_STATE_MISMATCH:
				return 'JSON_ERROR_STATE_MISMATCH';
			break;
			case JSON_ERROR_CTRL_CHAR:
				return 'JSON_ERROR_CTRL_CHAR';
			break;
			case JSON_ERROR_SYNTAX:
				return 'JSON_ERROR_SYNTAX';
			break;
			case JSON_ERROR_UTF8:
				return 'JSON_ERROR_UTF8';
			break;
		}

		return 'Unknown Json error' . json_last_error();
	}

$json='{"laptops":"26"
,null:"26"
,"cad":"26"}';
echo "\nstrlen(json) = " . strlen($json);
$dummy = json_decode($json, 1);
if (json_error()) die('Json Error: ' . json_error() . "\n");
?>

Hope this helps …

How to fix failed dependencies when installing rpm Sphinx Search on CentOs

2014/02/15 Leave a comment

Trying to install the open source Sphinx Search Engine on my CentOs Linux server I got these errors:


wget "http://sphinxsearch.com/files/sphinx-2.1.5-1.rhel6.x86_64.rpm"
rpm -i sphinx-2.1.5-1.rhel6.x86_64.rpm

error: Failed dependencies:
libodbc.so.2()(64bit) is needed by sphinx-2.1.5-1.rhel6.x86_64
libpq.so.5()(64bit) is needed by sphinx-2.1.5-1.rhel6.x86_64

It means there are some libraries left in the system. To find out which are they I used this command:


yum provides **/libpq.so.5

This way I could install the missing libraries:


yum install unixODBC unixODBC-devel postgresql-libs

And then, I tried again (successfully this time) to reinstall Sphinx Search:


# rpm -i sphinx-2.1.5-1.rhel6.x86_64.rpm

Sphinx installed!
Now create a full-text index, start the search daemon, and you're all set.

To manage indexes:
editor /etc/sphinx/sphinx.conf

To rebuild all disk indexes:
sudo -u sphinx indexer --all --rotate

To start/stop search daemon:
service searchd start/stop

To query search daemon using MySQL client:
mysql -h 0 -P 9306
mysql> SELECT * FROM test1 WHERE MATCH('test');

See the manual at /usr/share/doc/sphinx-2.1.5 for details.

For commercial support please contact Sphinx Technologies Inc at

http://sphinxsearch.com/contacts.html

I hope this tip can help someone …

Cheap|Bargain|Low cost dedicated Linux|CentOs servers

2012/12/12 26 comments

Several days trying to find a reliable dedicated linux server and found a lot of offers, but these are the best according to monthly fees and Gb RAM:

  • kimsufi/ovh 2Gb => 15$
  • digitalocean.com 2Gb => 20$
  • sagonet 2Gb => 24$
  • server4you 4Gb => 30$
  • xirra.net 8Gb => 38$
  • strato.es 4Gb => 38$
  • 1and1 2Gb => 40$
  • sagonet 4Gb => 50$
  • perfectip.net 4Gb => 50$
  • serverpronto 2Gb => 50$
  • hivelocity.net 2Gb => 50$
  • hostinganddesigns 1Gb => 50$
  • dinahosting 2Gb => 52$
  • hetzner.de 16Gb => 65$
  • godaddy 2Gb => 78$
  • worldstream.nl 4Gb => 80$
  • hivelocity.net 2Gb => 90$
  • serverbeach 4Gb => 130$
  • hostgator 4Gb => 175$

I hope you find this data useful. If you know a company offering better prices, please, let me know. Thanks!

linux-dedicated-servers

Follow

Get every new post delivered to your Inbox.