Wednesday, October 20, 2010

apache2 and sagemath both on port 80 using mod_proxy etc..

I want to run sage and apache2 both on port 80, but I can't do that. So a work around is to do port forwarding so it looks like like the user is on a regular website and they can't see the port numbers. I tried for too long just using mod rewrite but kept getting 403 and 500 errors. The final solution was really easy:

Put this in your HTTP.conf

DocumentRoot /var/www/sage/
ServerName sage.mysite.com
ServerAlias www.sage.mysite.com
ProxyRequests Off

Order deny,allow
Allow from all


ProxyPass / http://mysite.com:8000/
ProxyPassReverse / http://mysite.com:8000/

Sunday, October 17, 2010

Ubuntu server send SMS text messages to cell phone

Not sure if anyone else has wondered this, but I had a ubuntu email server and I wanted to set it up to send SMS message automatically so users on cell phones could get updates. Well, that is easy, just poin the email to:
10-digit wireless number@mms.att.net

For example
If my area code was 775 and my phone number was 111-3333 I would do:

7751113333@mms.att.net

So if I was using PHP my code would be:

$phoneNumber=7751113333
$to = $phoneNumber."@mms.att.net"; //combine phone number to send message
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
echo("

Message successfully sent!

");
} else {
echo("

Message delivery failed...

");
}

Wednesday, October 13, 2010

Running sage math on android OS / phone

So I dug around on the internet and I found someone who was patient enough to actually compile and install sage on their android G1.

Here is a photo:

photo


The build took 14.5 days and the conlcusion was for now you are much better off having a sage notebook
server. Maybe as stats continue to improve you can run one locally.

The original post can be read here:

I have compiled and run Sage 3.2.3 on my T-Mobile G1 cell phone, and
large portions of it actually work.

300 files had failing doctests; this means that all doctests passed in
864 files. A lot of the failing doctests are with pexpect (maxima,
gap, etc.); I don't know why these fail. When I try simple things
with gap and maxima, they do work. Many more tests fail due to
timeouts; the 300-second timeout is far too short for the G1.
(Doctesting any file with doctests takes >50 seconds; doctesting a
file with no doctests takes >4 seconds. The entire doctest run took
270724 seconds, or a little over 3 days.)

Unfortunately, it's far too slow to be useful for anything (just
starting Sage takes about a minute, if there's enough free memory; but
since Android likes to keep the memory full all the time, there never
is enough free memory, and it takes much longer to start). So I don't
plan to do anything further with the project.

Of course, the sensible way to do this is to find some nice fast
computer and set up a cross-compiler. I didn't do this the sensible
way; I actually did the build on the cell phone. And of course, the
build would stop every once in a while due to a bug, which I would
then patch around. So, adding up the 14 chunks of compilation
involved, the entire compile took 20943 minutes of real time (about
14.5 days) and 9438 minutes (about 6.5 days) of CPU time. You'll note
that the CPU time adds up to less than half of the real time; most of
the rest of the time was spent swapping. The G1 has about 100MB of
RAM; I set up a swap file on my micro-SD card, to allow the build to
proceed at all. On several files, the compiler uses more than 300MB.
While compiling those files, the CPU is typically less than 1% active;
I'm pretty sure that there were files that took more than a day to
compile. The phone was essentially unusable for smartphone activities
(web browsing, etc.) while the build was running. In fact, the whole
smartphone UI crashed and restarted on a fairly regular basis during
the build (I'm guessing it has some sort of watchdog timer and reboots
itself if it detects that some operation is taking an unreasonably
long time), but the build just continued anyway (running inside a
screen session).

The ATLAS tuning process took about 3.2 days (with almost as much CPU
time as real time; that didn't swap much). Skimming through the logs,
I see reports of numbers like 3 to 6 MFLOPs.

The build was performed inside a Debian armel testing chroot; it's
pretty nice being able to run real Debian on my cell phone.
(Everything works; I can ssh in and out, etc., although when it's on
the cell phone network, inbound connections are problematic because
it's behind a NAT.)

To make the whole project even more pointless, since the phone is
running real Debian (inside the chroot), I can probably just wait a
few weeks or months for Tim Abbott to get all the portability issues
fixed in the sagemath Debian package, and then install Sage on the
phone with apt-get.

Here's the processor:

cwitty@localhost:/tmp$ cat /proc/cpuinfo
Processor : ARMv6-compatible processor rev 2 (v6l)
BogoMIPS : 383.38
Features : swp half thumb fastmult edsp java
CPU implementer : 0x41
CPU architecture: 6TEJ
CPU variant : 0x1
CPU part : 0xb36
CPU revision : 2
Cache type : write-back
Cache clean : cp15 c7 ops
Cache lockdown : format C
Cache format : Harvard
I size : 32768
I assoc : 4
I line length : 32
I sets : 256
D size : 32768
D assoc : 4
D line length : 32
D sets : 256

Hardware : trout
Revision : 0080
Serial : 0000000000000000

Carl


http://groups.google.com/group/sage-devel/browse_thread/thread/243dfd4ab25a2779/ea5b45f313b46460

Wednesday, October 6, 2010

javascript replace all character occurances in one line

So if I have a string:

var myOldString = "x%=
%%%%0.4218%%%%0.7922
%%%%0.9157%%%%0.9595
";


And I want to replace all of the % with space I can use javascript and use the '/g' modifier to replace all:

temp = myOldString.replace(/%/g,' ');

If I had done:

temp = myOldString.replace('%',' ');

It would have only replaced the first occurance which was not what I wanted.

Tuesday, October 5, 2010

matlab eval 2 string linebreak to
eval2str.m

So I wanted my Matlab eval input to be made into a string I could post on a website.
The evalc() Matlab function returns a character array, but I wanted a string I could send through a socket to a website.

I had an issue with finding the exact line break, I tried char(10) and '\n' but that did not work so I cheated. Here is my cheat:

function STR2=eval2str(msg)
STR=evalc(msg) %eval input
A=evalc('X=2') %eval to get character? char(10) and \n did not work for me?
STR=strrep(STR,' ','%') %I justed used this to temporarily replace the spaces
STR2=strrep(STR,A(4),'
')
%ln2br

So if I input eval2str('X=rand(2,2)') I get a string like this:

x%=
%%%%0.4218%%%%0.7922
%%%%0.9157%%%%0.9595


Which is a string I can pass through my socket and then replace the % with ' ' on the otherside. So I can use Matlab to eval to a string output and send over a socket for a matlab server :).