Tuesday, 1 October 2013

nginx node.js & socket.io 504 timeout

nginx node.js & socket.io 504 timeout

Nginx config
server {
listen *:80;
server_name live.domain.com;
server_tokens off;
charset utf-8;
error_log /var/log/nginx/live-error.log info;
access_log /var/log/nginx/live-access.log;
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:1337;
proxy_redirect off;
}
}
When node.js is working everything is okay, but if node.js not started and
I try to load page http://live.domain.com/socket.io/socket.io.js it makes
me wait 30 seconds (read_timeout).
I want make it so, that if node.js not running I'm getting 404 or 502
error right away without 30 seconds waiting for timeout.
In other words: I need to check node.js on client side right away.

mod rewrite is not affected for domain without www?

mod rewrite is not affected for domain without www?

i have this setting for apache :
<VirtualHost mysite.co.id:80>
ServerAdmin admin@mysite.co.id
DocumentRoot /var/www/html/main
ServerName mysite.co.id
ErrorLog logs/mysite.co.id.error
CustomLog logs/mysite.co.id.access common
<Directory "/var/www/html/main/">
Options +Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
RewriteEngine On
RewriteRule ^/sub1(.*) http://sub1.mysite.co.id$1 [NC,R,L]
</VirtualHost>
<VirtualHost beta.mysite.co.id:80>
ServerAdmin admin@beta.mysite.co.id
DocumentRoot /var/www/html/beta
ServerName beta.mysite.co.id
ErrorLog logs/beta.mysite.co.id.error
CustomLog logs/beta.mysite.co.id.access common
<Directory "/var/www/html/beta/">
Options +Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
RewriteEngine On
RewriteRule ^/sub1(.*) http://sub1.beta.mysite.co.id$1 [NC,R,L]
</VirtualHost>
<VirtualHost www.mysite.co.id:80>
ServerAdmin admin@www.mysite.co.id
DocumentRoot /var/www/html/main
ServerName www.mysite.co.id
ErrorLog logs/www.mysite.co.id.error
CustomLog logs/www.mysite.co.id.access common
<Directory "/var/www/html/main/">
Options +Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
RewriteEngine On
RewriteRule ^/sub1(.*) http://sub1.www.mysite.co.id$1 [NC,R,L]
</VirtualHost>
this condition will redirect for all sub1 folder accessed will be redirect
to our new subdomain sub1.
all work for beta.mysite.co.id and www.mysite.co.id but failed for
mysite.co.id
what i miss from here? i have check my /var/log/mysite.co.id but only my
php error listed there and it's one month ago :
[Mon Sep 02 10:28:10 2013] [error] [client 128.21.30.30] File does not
exist: /v
ar/www/html/favicon.ico
[Mon Sep 02 10:29:10 2013] [error] [client 128.21.30.30] Directory index
forbidd
en by Options directive: /var/www/html/
[Mon Sep 02 10:29:29 2013] [error] [client 128.21.30.30] File does not
exist: /v
ar/www/html/mysite
[Mon Sep 02 10:29:34 2013] [error] [client 128.21.30.30] Directory index
forbidd
en by Options directive: /var/www/html/
[Mon Sep 02 10:30:15 2013] [error] [client 128.21.30.30] Directory index
forbidd
en by Options directive: /var/www/html/
my system :
PHP Version 5.3.3
Apache/2.2.15 (CentOS)
Linux my.centos 2.6.32-358.18.1.el6.x86_64

update:
everything changing line inside mysite.co.id will not affected the page,
but i ping all mysite.co.id, www.mysite.co.id and beta.mysite.co.id will
refer to the same IP

Monday, 30 September 2013

jemalloc error making redis on centos 6.4 [on hold]

jemalloc error making redis on centos 6.4 [on hold]

I am setting up a new, dedicated, centos 6.4 system with redis. I have
installed redis many times, but have never hit this issue (and have never
been on centos 6.4 before).
cd redis-2.6.16
sudo make install
error:
sh: ./mkreleasehdr.sh: Permission denied
and later:
zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
zmalloc.h:55:2: error: #error "Newer version of jemalloc required"
When I try to build jemalloc directly (from the /src area of the redis
tarball), other errors include:
cd src && make jemalloc
sh: ./mkreleasehdr.sh: Permission denied
make[1]: Entering directory `/tmp/rediswork/redis-2.6.16/src'
make[1]: *** No rule to make target `jemalloc'. Stop.
make[1]: Leaving directory `/tmp/rediswork/redis-2.6.16/src'
make: *** [jemalloc] Error 2
I also tried redis 2.6.7 and have the same issue.
I have dug all over and can find no path forward.

Questions about tangent spaces of $A^n$.

Questions about tangent spaces of $A^n$.

Let $A^n=k\times \cdots \times k$ be the affine $n$-space, $k$ is a field.
Define $d_xf = \sum_{i=1}^n \frac{\partial f}{\partial T_i}(x)(T_i-x_i)$,
where $x=(x_1, \ldots, x_n) \in A^n$.
Suppose that $X \subset A^n$ is defined by polynomials $f(T)=f(T_1,
\ldots, T_n)$. Define $$ \operatorname{Tan}(X)_x = \{x \in A^n \mid
d_xf(x) = 0, \forall f(T) \in I(X) \}. $$
Suppose that $I(X)$ is generated by $f_1(T), \ldots, f_m(T)$. Then each
element in $I(X)$ is of the form $a_1f_1+\cdots +a_nf_n$ for some $a_i \in
I(X)$. How to show that $d_xf_1, \ldots, d_xf_m$ generated by ideal of
$\operatorname{Tan}(X)_x$? Thank you very much.
I think that the ideal of $\operatorname{Tan}(X)_x$ is $$ \{f \mid f(x) =
0, \forall x \in \operatorname{Tan}(X)_x \}. $$ If $x \in
\operatorname{Tan}(X)_x$, then $d_xf(x)=0$ for all $f\in I(X)$. That is,
$d_xf(x)=0$ for all $f$ which are of the form $a_1f_1+\cdots a_mf_m$.
Therefore the ideal of $\operatorname{Tan}(X)_x$ is contained in the ideal
generated by $d_xf_1, \ldots, d_xf_m$. If $f$ is generated by $d_xf_1,
\ldots, d_xf_m$, we also have $f(x)=0$ for all $x \in
\operatorname{Tan}(X)_x$. Hence $x$ is in the ideal of
$\operatorname{Tan}(X)_x$. Is this correct? Thank you very much.

Comparing php array key value

Comparing php array key value

I am trying to compare two array value. My array1 is like
$a1= array('123' => 'test1, '456' => 'test2', '789' => 'test3')
array2 is like
a2=array('456' => 'match2', '99' => 'match3')
a3 = array();
I want to compare the key value. If array1 key matches array2 key, push
array1 element to a new array
I have
for($i=0; $i < count($a1); $i++){
//i am not sure how to write my codes heree......
if($a1[$i]==a2[$i]{
$a3[]=a1$[$i];
}
}
Can someone help me out on this? Thanks a lot!

SIMULINK - Effects of Tunable/Changable Parameters in a masked subsystem when using Embedded Coder

SIMULINK - Effects of Tunable/Changable Parameters in a masked subsystem
when using Embedded Coder

I have a masked subsystem (in SIMULINK) containing several tunable
parameters. There is a stage where my model will have to be code-generated
(using Embedded Coder) and used for real-time testing and investigation.
What I am not sure about is the effect of using tunable parameters for a
model that requires code generation. I know that people will now
scream,"Why don't you just do it and see what happens?". I have been
waiting for my Embedded Coder license and trying to derisk my models
meanwhile. Without any expert suggestion, I have no way to determine this.
Could anyone please advise?
KR,

Sunday, 29 September 2013

php foreach shows only results for an x result in one of my rows

php foreach shows only results for an x result in one of my rows

There is a forech search, I want to get the results only where $postType<2
. How can I amend my code?
<?php
if ($resultSearch){
foreach ( $resultSearch as $row ){
$idPost=$row['idPost'];
$postType=$row['type'];
$postTypeName=getTypeName($postType);
$postTitle=$row['title'];
$category=$row['category'];//real category name
$fcategory=$row['fcategory'];//frienfly name category
$idCategoryParent=$row['idCategoryParent'];
$fCategoryParent=$row['parent'];
$postImage=$row['image'];
$insertDate=setDate($row['insertDate']);
if ($row["hasImages"]==1){
$postImage=getPostImages($idPost,$insertDate,true,true);
}
else $postImage=getPostImages(true,true,true,true);//there's no image
$postUrl=itemURL($idPost,$fcategory,$postTypeName,$postTitle,$fCategoryParent);?>