Thursday, 3 October 2013

PHP POST Code Cleanup

PHP POST Code Cleanup

Is there a better way to using post data rather then defining the
variables manually?
My Current Method
<form method="POST" action="form.php">
<input type="text" name="name" id="name" />
<input type="submit" value="Submit">
</form>
<?php
$name = $_POST['name'];
function echoname ($name) {
echo $name;
};
echo "This is my new" . echoname ($name);
?>
Now I know you can just go like this for my example however it is only an
example:
<?php
$name = $_POST['name']
echo "This is my new" . $name;
?>
Is there a better way to use $_POST['value'] without having to define the
post data as a variable every time?
As a note, i have looked here: PHP Manual $_POST already
Thanks!

Wednesday, 2 October 2013

#2003 - The server is not responding

#2003 - The server is not responding

Can anyone help me?
I am using win 7 ultimate 64bit I bought a software that only use appserv
242. but appserv 242 cant start apache. So what i did is I installed the
software which has mysql in it. and then i installed appserv 249 so that i
can open phpmyadmin.
I can run the software. When I tried opening the databse using phpMyAdmin
it shows error message:
#2003 - The server is not responding.
What should I do so that I can access the database using phpMyAdmin?

SQL Join - multiple tables in same row

SQL Join - multiple tables in same row

We're developing a PHP page to create some reports. We're using data from
a database that is "populated" by a third-party application.
We need to execute a query to select "tickets" between a period and to
select other data from another table.
Example:
//Select tickets closed between dates
SELECT *
FROM ticsummary
WHERE resolution_date between #07/04/2013# AND #08/04/2013#;
//Result
Ticket Resolution_date
61968 07/04/2013This (above) is working great. However we need to add a
content that is in another table named "ticFieldVals". The content from
this table is:
ticId fieldId intVal numVal strVal
61968 1 4 Voz NULL NULL
61968 2 3 Closed NULL NULL
61968 3 2 NULL NULL
61968 100 2 NULL NULL
61968 103 NULL 300.000 NULL
61968 85253767 0 NULL NULL
61968 73913495 1 NULL NULL
61968 23260488 NULL NULL
61968 83015458 1 NULL NULL
61968 33742201 1 NULL NULL
61968 57589628 1 NULL NULL
61968 91660570 NULL NULLSo I need to execute a "join", to have
both of these tables in just one table. However the content of
ticFieldVals there is a lot of rows, and I need to put all together in
same row.
I'm sure if you can totally understand, but any help is greatly appreciated.

Delete substring from the end of string

Delete substring from the end of string

I would like to do the following in C. I have string like unsigned char
out[CHUNK]. And I would like to remove everything after a substring "LEN "
in out[CHUNK]. I do not know the position of LEN. It can appear anywhere.
Thank you

R - Forecasting Har model

R - Forecasting Har model

I'm currently completing my MSc dissertation, using R to build a realised
volatility model using HAR.
There is a great guide on using high frequency in R which has been
invaluable to me. I was wondering though if you could all help with one
issue?
I've successfully achieved page 16 example in this pdf:
http://cran.r-project.org/web/packages/highfrequency/highfrequency.pdf
However, I would like to forecast the model into the future for a few
periods. So far I have had no success and it doesn't seem to let me
forecast harmodel like an ar model.
Do you have any suggestions? I thought it would be relatively easy to
extend the forecast that takes place in the example you already provided.
My dissertation would be grateful for any help you can offer.
Thanks very much, Stephen Donnelly
P.S:
rm(list=ls(all=TRUE))
library("highfrequency")
log.ret <- function(x) { y <- diff(log(x)); return(y) }
x <- as.matrix(read.csv("C:/users/u590799/Desktop/DATA-TEST.csv"))
dates <- x[,1]
times <- x[,2]
values <- as.numeric(x[,3])
times[which(times=="")] <- "00:00:00"
date.n.time <- matrix(NA, NROW(x), 1)
for(i in seq(1, NROW(x), 1)){date.n.time[i,1] <- paste(dates[i],
times[i], sep=" ")}
date.n.time2 <- as.Date(as.character(date.n.time), "%Y-%m-%d %H:%M:%OS")
x <- as.matrix(values); rownames(x) <- date.n.time; colnames(x)
y <- log.ret(x) #5 min log returns
y <- as.xts(y)
setwd("C:/Users/u590799/Documents/QUB/RV/Output")
fname <- "The New Style-Settings-Normalised"
y.out <- harModel(data=y, periods = c(1,5,22),RVest = c("rCov"),
type="HARRV",h=1, transform=NULL)
capture.output(summary(y.out),file=paste(fname, "out-summary.txt",
sep="-"))
pdf(file=paste(fname, "out-plot.pdf", sep="-"), paper="a4r", width=12
, height=11.7); plot(y.out); dev.off()

Tuesday, 1 October 2013

How to serve cached images in django sorl-thumbnails ? It's raising 404s

How to serve cached images in django sorl-thumbnails ? It's raising 404s

I'm new to sorl-thumbnail and I am generating thumbnails that behave like
they should work fine but they don't. Here's an example of what I'm doing
{% thumbnail
"http://www.tlswebsolutions.com/wp-content/uploads/2012/03/django-logo-negative.png"
"200x200" as im %}
<img src="{{ im.url }}">
{% empty %}
<p>No image</p>
{% endthumbnail %}
I'm using memcached with the default configuration and the stats look like
my thumbnails are actually stored in the cache. The thumbnail appears in
the my folder /proj/myapp/cache/x/xx/xx.jpg
But the site raises a 404. Which I think is normal, as there is no URL
pointing to that /cache directory.
I checked the doc, they don't seem to say that there is anything
particular to do about this. Did I miss an obvious step somewhere ?
Thanks a bunch!

AJAX not working after rewrite using htaccess

AJAX not working after rewrite using htaccess

my ajax script is not working after applying rewrite rule. The ajax script
is in page http://raymondmiranda.com/image-gallery
my htaccess code is:
RewriteEngine On
# Unless directory, remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ /$1 [R=301,L]
# Redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ /$1 [R=301,L]
# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]
#Default Page
DirectoryIndex home.php

What is an intuitive definition of the zero vector=?iso-8859-1?Q?=3F_=96_math.stackexchange.com?=

What is an intuitive definition of the zero vector? – math.stackexchange.com

I'm learning now about vector spaces and subspaces, and one of three rules
that determine if something is a subspace of a larger vector space is that
it must contain the zero vector... but ...

Question regarding Ito Process

Question regarding Ito Process

I am new to Ito Process, so I have a following question. Consider a
standard Ito Process, $$X_t=X_0+\int_0^t\mu_sds+\int_0^t\sigma_sdW_s$$
where W is the m-dimentional Brownian motion and X is a n-dimentional
process. $\mu$ and $\sigma$ are adaptive to {$\Sigma_t$} generated by the
Brownian motion. In somewhere in my textbook, it says the drift and the
variance can be derived as following, $$\frac{d}{ds}
E(X_s|\Sigma_t)|_{s=t}= \mu_t $$ and $$\frac{d}{ds}
Var(X_s|\Sigma_t)|_{s=t}= \sigma_t\sigma_t^T$$ I thought this is trivial
and attempted to prove it myself, however it took me nearly an hour, and
can't even show the first one..
I tried the following way, $$\frac{d}{ds} E(X_s|\Sigma_t)|_{s=t}=
\frac{d}{ds}
E(X_0+\int_0^s\mu_sds+\int_0^s\sigma_sdW_s|\Sigma_t)|_{s=t}$$$$=\frac{d}{ds}
E(X_0|\Sigma_t)+\frac{d}{ds}E(\int_0^s\mu_sds)+\frac{d}{ds}E(\int_0^s\sigma_sdW_s|\Sigma_t))$$
Then I feel that the last term should be zero by the independent increment
property, but not 100% sure I can use here, inside the integral there is
$\sigma_s$, then I don't know how to proceed from here and get the above
two equation.
Any help will be extremely appreciated!!