School Algebra Story Problems

This was taken from Marvin Minsky’s Why programming is a good medium for expressing poorly understood and sloppily-formulated ideas.

Mary is twice as old as Ann was when Mary was as old as Ann is now. If Mary is 24 years old, how old is Ann?

My school problems weren’t worded in quite this confusing a way.

IpTables

Task

Write a iptables script that blocks everything except ping (icmp) and ssh (port 22), http (80) and https (443).

Solution

-m says load a module state which allows access to the connection tracking state of the packets
–state precedes a comma separated list of the connection states to match. In this case it’s NEW.
NEW the packet has started a new connection or a connection that has not seen packets going in both directions
-m tcp load the tcp module (just like we loaded the state module) this module allows us extra functionality with tcp
-p tcp specifies protocol, in my case TCP
–dport 22 feature provided by the -m tcp module, in this case I want the rule to be applicable to port 22 (ssh).
-j ACCEPT means the results of this chain is to accept the packets. (-j specifies the target of the rule if the packet matches the rule. If I said -j DROP we would block all traffic to port 22).

Saving Real Media streams

I like to watch Berkley’s stream lectures. I do not like to have to start
at the beginning of a lecture and wait for the buffer to catch up to where I
was last time before I got interrupted. After some googling I was able to find
out how to save real media streams with mplayer.

Bellow is a bash script I wrote in order to download EE 140
lectures:

-bandwidth 2000000 set the download rate to 2Mbps without this data downloads
in real time which means it takes 60 minues to download a 60 minute lecture.
-cache 3000 is useful because you are downloading a lot faster than real time
-noframedrop and -dumpfile should be pretty self explanatory
-rtsp is the proprietary protocol which real media streams with
$url is taken from inspecting the .rm files

As far as I know this method can be employed for any streaming media mplayer
can playback. I haven’t tried it on anything except the Berkley lectures.

Refereces:
http://ubuntuforums.org/showthread.php?t=635058
http://thomer.com/howtos/capture_realstream.html <– howto stream audio only