Monday, December 27, 2010

How to show octave line by line output in real time

So octave will output everything from your script once it ends by default. This can be frustrating if you are trying to troubleshoot a lot of looping. To get the real time line by line output like Matlab you need to include:

more off;

At the beginning of your script. If you like you can put this in your octaverc startup file so you don't have to do this for each script. Hope that saves someone some time.

Tuesday, November 30, 2010

How to install google chrome browser behind firewall, download standalone

I had issues installing google chrome since I was behind a firewall and it would fail. You can install google chrome by downloadingthe alternative standalone install which is larger but saves you the issue of installing behind a firewall or proxy:
Here is the link:

Saturday, November 27, 2010

Thursday, November 4, 2010

Python max index numpy.argmax(asarray(

So in Matlab I loved how I could do:

[A I]=max(Array)

And get I the index of the maximum value. To do this in sage (python) I finally ended up with this command:


Where Array is my python list, I have to use asarray() to convert it to a numpy array. Then the argmax returns the first occurrence of the maximum.

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/
ProxyRequests Off

Order deny,allow
Allow from all

ProxyPass /
ProxyPassReverse /

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

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

So if I was using PHP my code would be:

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

Message successfully sent!

} else {

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:


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


Wednesday, October 6, 2010

javascript replace all character occurances in one line

So if I have a string:

var myOldString = "x%=

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

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

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


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 :).

Tuesday, August 24, 2010

Create great latex PDF figs using Open Office Draw

I found out that I can use open office Draw to make great vector graphic presentations and then import that into my latex articles and latex beamer presentations. Here is what you do:

1: Export your as PDF from OpenOffice Draw

If I saved my file as CoolFigure.pdf then I would do:

2. pdftops -eps CoolFigure.pdf
3. cat CoolFigure.eps | ps2eps > CoolFigure.eps && epstopdf CoolFigure.eps

Then to include it in my Latex document I just do:

4. \begin{figure}

Saturday, July 31, 2010

How to install Matlab on ubuntu server 10.04 via command line

So I did not have x-server install on the server and it was not allowing me to do the GUI install. So instead I tried:

./install -t

for the text install but I got an error after the license agreement:
update/bin/glnxa64/xsetup: error while loading shared libraries: cannot open shared object file: No such file or directory

I did this:

apt-get install libxp6

and then it worked just fine using ./install -t
Hopefully this saves somebody some time, and stops them from doing a ubuntu-desktop install on a server just to install Matlab

Thursday, July 8, 2010

True multithreading in PHP! Spawn new threads in webpage

Ok, so I searched around for this and I was disappointed, I could not find true multithreading in PHP. Well here is my solution. You know how you can call php from the command line in linux/unix? Well you can do a system call to a php function, hide the output and break off of it and come back to the website and your php script will continue executing in the background.

Here is an example:

So from the command line I can do:


well there is no reason you can't call the a system call from your website, so I am doing something like this:

$exec_string="php -r 'PUT_YOUR_PHP_CODE_HERE_WITHOUT_ESCAPES' > /dev/null 2>&1 &";

The command: 2>&1 & at the end is what I am using the escape the string rather than waiting for it to finish.

$exec_string="php -r 'mail(\"".$_POST['user']."\",\"".$string1."\",\"".$bericht."\",\"".$string2."\");' > /dev/null 2>&1 &";

Monday, January 11, 2010

How to install SAPPHIRE HD5770 on ubuntu 9.10 and get it working

First go to ATI's website and download:

Now run:

sudo aticonfig --initial -f

Then reboot and settings worked just fine allowing me to configure advanced desktop settings

Wednesday, January 6, 2010

IP addresses you should hack and not feel bad about

Here is a list of banned IP addresses you can try hacking and not feel bad. These IPs spammed one of my websites so I was able to grab them.

Edit Delete 1
Edit Delete 2
Edit Delete 3
Edit Delete 4
Edit Delete 5
Edit Delete 6
Edit Delete 7
Edit Delete 8
Edit Delete 9
Edit Delete 10
Edit Delete 11
Edit Delete 12
Edit Delete 13

Let me help you get started:
Using the UNIX command NMAP you can do:

nmap -A -T4 to find out what services are running. The ouput for this IP is:

SCRIPT ENGINE: Aborting script scan.
Interesting ports on (
Not shown: 1708 filtered ports
22/tcp open ssh (protocol 2.0)
80/tcp open http Apache httpd 2.2.11 ((Ubuntu) PHP/5.2.6-3ubuntu4.2 with Suhosin-Patch)
443/tcp closed https
5900/tcp closed vnc
5901/tcp closed vnc-1
5902/tcp closed vnc-2
5903/tcp closed vnc-3
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at :

Some areas to start would be trying to do a brute force on the SSH server, or VNC server incase the password was simple, or find vulnerabilities in the webserver, the kernel may have a security hole since it is older... etc.. etc..

Friday, January 1, 2010

You have not chosen to trust "Thawte Premium Server CA", the issuer of the server's security certificate (SSL error 61) ubuntu citrix ICA client FIX

You have not chosen to trust "Thawte Premium Server CA", the issuer of the server's security certificate (SSL error 61) ubuntu citrix ICA client FIX.

I use a citrix ICA client to remote into work and I began to get the error:
You have not chosen to trust "Thawte Premium Server CA", the issuer of the server's security certificate (SSL error 61)

To fix this I downloaded the new root certificates:

Now we need to find were we need to put the new cert file, I found this by searching doing this:
find -name *cacert*

I copied the new file using this command:
sudo cp -v Thawte\ Roots/Thawte\ SSLWeb\ Server\ Roots/Thawte\ Premium\ Server\ CA.cer ~/./ICAClient/linuxx86/keystore/cacerts/ThawtePremiumServerCA.crt

Then I retried the citrix ICA client, did not even need to restart my browser, and it worked!