October 2009
1 post
3 tags
Java: Remote Method Invocation
The Java RMI (Remote Method Invocation) is a way to create distributed services. It is composed of RMIRegistry which is a name registry which saves the resources available (servers) in a JVM (Java Virtual Machine). The registry is, however, accessible through different JVM’s when configured.
Since all the invocations are remote, most arguments are passed by value.
The exception is when an...
August 2009
5 posts
2 tags
FTP in Python
In Python, to create and maintain a FTP communication, the ftplib or urllib (explained in a future post) can be used.
Creating a FTP connection
from ftplib import FTP
try:
conn = FTP('almightybuserror.com')
except:
print "Could not connect to almightybuserror.com."
return
Logging in…
For anonymous log in:
try:
conn.login()
except:
print "No anonymous connections...
2 tags
HTTP in Python
To create and HTTP connection we use the httplib module which provides some simple yet effective methods to create a connection and send requests to an HTTP server. The module urllib can also be used and is easier, does, however only perform GET requests (explained in a future post).
Creating a connection
To create a connection, the method HTTPConnection does the job. For example:
import...
Scripts and Tools Repository
I recently created a github repository for my tools, it can be found here.
Feel free to check it out!
4 tags
Snippet.Py: Getting an image resolution
Using PIL (Python Image Library) it is possible to get the width and height of a image using the property size.
The following example will take an undefined number of arguments and print all the resolutions:
import Image
import sys
def main():
argv = sys.argv[1:]
if (len(argv) == 0):
print "No file given!"
else:
for name in argv:
img = Image.open(name)
...
June 2009
5 posts
Slowloris - HTTP DoS →
1 tag
Source The Daily Show
The first few milliseconds of an HTTPS Connection. →
The better you program, the worse you comunicate. →
1 tag
May 2009
13 posts
1 tag
4 tags
Multicast: An UDP strong point
Multicast is a way to distribute UDP messages to multiple hosts in an automated fashion. It works by making every host join a group which is composed of an IP address in the range [224.0.0.0 - 239.255.255.255] and a port. Every message sent to a group will be delivered to every host that has joined it.
Since it can generate alot of traffic, multicast is only used at a LAN or intranet level.
In...
2 tags
4 tags
HTTP Proxy: Java Implementation
Continuing from “Concept Introduction” we will now see how a possible implementation is done.
To start implementing a proxy we must first create a simple server application which accepts a connection from a client to be redirected.
Creating Server
We start by creating a ServerSocket (for more information go here).
doIt( new ServerSocket( serverPort ) );
Now we need to implement...
2 tags
COMIC SANS IS HERE TO SAVE THE DAY!
Original: http://www.collegehumor.com/video:1908292
3 tags
Snippet.Cpp: Comparing Types of Classes
This snippet shows how to differentiate between two classes that have heritage from the same class.
Using the following classes:
class A {}
class B: public A { B(); }
class C: public A { C(); }
With the following variables:
A a;
A *b = new B();
A *c = new C();
if(typeid(b) == typeid(a))
cout << "First is true" << endl; // A* != A
if(typeid(*b) == typeid(B))
cout <<...
2 tags
Snippet.Java: Dump InputStream → OutputStream
This piece of code keeps reading 1024 bytes from the InputStream and writing to the OutStream until the read function returns an error value (-1) which means there is not anything else to read.
protected void dumpStream( InputStream in, OutputStream out )
throws IOException {
byte[] arr = new byte[1024];
int n;
do {
n = in.read( arr );
out.write( arr, 0, n );
}...
1 tag
The question is what’s a Mahna Mahna?
The question is who cares?
– http://www.youtube.com/watch?v=q5I3yZSYOCA
3 tags
HTTP Proxy: Concept introduction
An HTTP proxy is a program that acts as a seamless server (since the user does not notice its existence under normal circumstances) and forwards HTTP (Hyper Text Transfer Protocol) traffic.
A problem for people that are creating a proxy for learning purposes is that most browsers nowadays days use HTTP/1.1 which is far more complex than its HTTP/1.0 counterpart implementation-wise. For this very...
Truth about xCode →
2 tags
2 tags
Threading in Java
A thread is a lightweight process that will act as the child of the process that created it. If the parent process is interrupted the child will be inherited by the kernel process, however, most of the times when the parent dies and child loses its purpose.
A thread will seemingly run at the same time as the other processes which raises concurrency issues but this won’t be discussed in this...
2 tags
Snippet.C: Getting the length of an array.
The following C macro gets the amount of memory the array uses and divides it by the size of the first position:
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x)[0])
Credits go to meqif.
April 2009
5 posts
1 tag
Added comment system
I chose to use Disqus as a comment system for Almighty Bus Error.
Feedback about that post is encouraged.
Thank you.
2 tags
Snippet.Py: Showing all the filenames in a...
The following Python code prints the name of the chosen directory and all the files in it and then proceeds to print all the files in the other nested directories one nested directory at a time.
This method is recursive for nested directories.
def print_dir(loc):
print loc + "\n"
for root, dirs, files in os.walk(loc):
for f in files:
print f + "\n"
for d in...
3 tags
The connection-oriented network protocol
The TCP (Transmission Control Protocol) and unlike UDP it does have a connection definition within the protocol based on Acknowledge-type packets.
In TCP every sent information packet needs to be acknowledged by the destination and if it is missing, the packet is resent until there is confirmation thus creating a “connection” between two peers. If a packet is corrupted a request is...
1 tag
3 tags
The connectionless networking protocol
Also known as UDP (User Datagram Protocol), like the title suggests, it does not have a logical idea of connection.
The way it communicates is by datagrams (or messages). The protocol is not able assert any type of confirmation at a transport layer level if a message got thru to the destination. A collateral effect of this is that UDP is a very lightweight protocol, perfect for scenarios where...
March 2009
1 post
1 tag
The awakening of the Almighty Bus Error
After a semester of C programming with operating system manipulation objectives (forking processes, concurrent problems etc), the “Bus Error” beast threatens awakening once more within the next weeks programming C to… Learn C all over again… Ok, its not much of a threat, but since I fail quite a bit, always be prepared.
Now for a description of what this blog will be...