Feed on
Posts
Comments

Blogging from a tent

Since its raining, and I find it far too exciting to blog, I just thought I would let you all know that I am in my new tent! I got a Big Agnes Emerald Mountain SL3 (for $205 - dont ask me how), and I thought I would try it out in the yard. It’s awesome! Loads of room and waterproof right from the get-go. I am impressed Big Agnes!

If only thunderstorms and daisy-chained extension cords went together just a little bit better…

Today, I have some unfortunate news to bring to you - One of my high school friends has gone missing. Her name is Rachel Lynn Martel.

She has been missing since 5/28/2009 (as of this post, 12 days).

If you see Rachel, please call the Essex Police Department at 802-879-4923. As I gather more information, it will be posted here.

Ok, so I haven’t written in a while. I did a stint with a military contractor and made a robot. I’ve been busy! This, however, demanded just a lick of attention. The Secret of Invisibility.  Are you f***ing kidding me internet? Really? Really? Cause I thought we tried to avoid stuff that is so clearly bull. Guess not.

Heck, I almost feel bad for sending them the traffic.

The total yahoo selling this bunk can be reached at:

W. Williams, Bill
PO Box 513
Rumney, NH 03266

Or, over the phone 603-786-0000 (it looks like a fake number, but its what he has listed.)

Legal: I in no way suport the product featured at http://www.thesecretofinvisibility.com/. In fact, I think its unbelievable that they try to sell such utter s**t.

DIY Military Keyboard!

p1030548Recently, I came across a very cool Military Keyboard on ebay. After making an offer and getting one in the mail, I discovered that it had an interesting connector on it. So, naturally, I began the process of converting the keyboard from whatever connector it had on there, to USB. 

Continue Reading »

This simple C program lists all of the “up” network interfaces on a linux system, along with their IP address and MAC address.

It prints off the bound IP address as well as the MAC address of the interface. A older version of this program can be found at http://www.doctort.org/adam/. The updates made to this version are IPv6 compatability and a fix of the “segfault” bug that was a problem in the first version. This version should compile and run on any linux system.

/*
 * Updated code to obtain IP and MAC address for all "up" network
 * interfaces on a linux system. Now IPv6 friendly and updated to use
 * inet_ntop instead of the deprecated inet_ntoa function. This version
 * should not seg fault on newer linux systems
 * Authors: Adam Pierce, Adam Risi
 * Date: 2/17/2009
 * http://www.adamrisi.com
 * http://www.doctort.org/adam/
 *
 * Previous file header follows:
 *
 * Example code to obtain IP and MAC for all available interfaces on
 * Linux.
 * by Adam Pierce <adam@doctort.org>
 * http://www.doctort.org/adam/
*/
 
#include <sys/ioctl.h>
#include <net/if.h>
#include <netinet/in.h>
#include <string.h>
#include <stdio.h>
 
/* 
 * this is straight from beej's network tutorial. It is a nice wrapper
 * for inet_ntop and helpes to make the program IPv6 ready
 */
char *get_ip_str(const struct sockaddr *sa, char *s, size_t maxlen)
{
  switch(sa->sa_family) {
  case AF_INET:
    inet_ntop(AF_INET, &(((struct sockaddr_in *)sa)->sin_addr),
	      s, maxlen);
    break;
 
  case AF_INET6:
    inet_ntop(AF_INET6, &(((struct sockaddr_in6 *)sa)->sin6_addr),
	      s, maxlen);
    break;
 
  default:
    strncpy(s, "Unknown AF", maxlen);
    return NULL;
  }
 
  return s;
}
 
int main(void)
{
  char          buf[1024] = {0};
  struct ifconf ifc = {0};
  struct ifreq *ifr = NULL;
  int           sck = 0;
  int           nInterfaces = 0;
  int           i = 0;
 
  /* Get a socket handle. */
  sck = socket(AF_INET, SOCK_DGRAM, 0);
  if(sck < 0) {
    perror("socket");
    return 1;
  }
 
  /* Query available interfaces. */
  ifc.ifc_len = sizeof(buf);
  ifc.ifc_buf = buf;
  if(ioctl(sck, SIOCGIFCONF, &ifc) < 0) {
    perror("ioctl(SIOCGIFCONF)");
    return 1;
  }
 
  /* Iterate through the list of interfaces. */
  ifr = ifc.ifc_req;
  nInterfaces = ifc.ifc_len / sizeof(struct ifreq);
  for(i = 0; i < nInterfaces; i++)
    {
      struct ifreq *item = &ifr[i];
 
      /* Show the device name and IP address */
      struct sockaddr *addr = &(item->ifr_addr);
      char ip[INET6_ADDRSTRLEN];
      printf("%s: IP %s",
	     item->ifr_name,
	     get_ip_str(addr, ip, INET6_ADDRSTRLEN));
 
 
      /* Get the MAC address */
      if(ioctl(sck, SIOCGIFHWADDR, item) < 0) {
	perror("ioctl(SIOCGIFHWADDR)");
	return 1;
      }
 
      /* display result */
      printf(", MAC %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
	     (unsigned char)item->ifr_hwaddr.sa_data[0],
	     (unsigned char)item->ifr_hwaddr.sa_data[1],
	     (unsigned char)item->ifr_hwaddr.sa_data[2],
	     (unsigned char)item->ifr_hwaddr.sa_data[3],
	     (unsigned char)item->ifr_hwaddr.sa_data[4],
	     (unsigned char)item->ifr_hwaddr.sa_data[5]);
 
    }
 
  return 0;
}

This code can be compiled by running:

$ gcc -o ifenum ifenum.c

Enjoy!

Everyone out there knows that emacs is the superior editor, right? Good! Now - you might have been programming recently and wished emacs was a little more frendy. GUI based editors have tabs, nice programming and documentation features, and little gems like autocompletion. Why, oh why doesn’t emacs have all this? Oh, it does!

  • Doxymacs - this package for emacs supports auto inserting comments for C and C++ code (at the beginning of files and before functions). Works great and makes your code beautiful!
  • M-/  - its not even a package! This little key-combo will autocomplete words based on the current open buffers. It does a great job on those lengthy variable names.
  • tabbar mode - Ever wished you could view your xemacs buffer list as tabs? Viola!

Those are just some of the great features emacs boasts. Whats your favorite?

So, you noticed that there is someone out there doing something nasty to your computer. Block their IP! Pulled directly from my .bashrc, I give you the most useful alias I have ever written:

alias blockip='sudo iptables -A INPUT -j DROP -s '
alias blockmac='sudo iptables -A INPUT -m mac -j DROP --mac-source '

Also included there is the ability to block a MAC address, just in case the attacker changes their IP. If you add those lines to your .bashrc, then blocking an IP/MAC is as easy as

$ blockip 1.2.3.4
$ blockmac 01:02:03:04:05:06

Just a last note, this only blocks incoming packets, not outgoing. Generally, this should be good enough to stop an attacker. Enjoy!

Worst. Name. Ever.

Todays post is short - but oh so sweet. Rember the marketing mistake named the “Chevy Nova”? Well, following in Chevys path of terrible names for mediocre products comes an MP3 player that, well, takes the cake. Without further ado - 

The TrekStor i.Beat Blaxx (”I beat blacks”)

They shortly after releasing the player renamed it, but you can still get a hint of the year-old fiasco from gizmodo.

To: Cygnus

Subject: Patent rights

Hey Cygnus! I recently was made aware of your patent infringement case against Google, Microsoft, and Apple concerning the use of “file preview technology.” While I am happy to see that you are ready to play in the big leagues, I have some terrible news for you:

You’ve already lost.

Google, Microsoft, and Apple were not even close to the first entities to employ icon-based previewing of files. A little look back in time, and you will find that the idea has been around since the unix days. There are open source implementations, it is a feature in most operating systems, and even shows up in on-line applications in file browsing or upload tools. Due to the fact that this technique has been around since, say, before 2001 (when you applied for a patent), I would hazard a guess that you getting a patent on the idea was a faux-pas by a patent clerk. 

Hey, even if it was a mistake, it was approved, right? Can you win? No, you can’t. Cygnus, you lost for one simple reason - money. Apple, Google, and Microsoft are technology giants with the resources to make you dissappear. Now, they may choose to do that with a quiet pay-off to keep this out of court, but asking for royalties? Forget it. Here’s a rule - If an idea was implemented in open source code prior to being patented, you are out of luck.

Besides, I’m certainly not going to remove any features from my precious linux distro. So there.

Your friend,

Adam Risi

Articles:

Hey all:

So, I am a little embarrassed to admit that this is my second python program, but happy to say that it works well, and is quite readable. Just thought I would share a simple quicksort in python:

def getFunc(array, x, func):
    ret = []
    for num in array:
        if func(num, x):
            ret.append(num)
    return ret
 
lessThan = lambda x, y: x < y
greaterThan = lambda x, y: x > y
equal = lambda x, y: x == y
 
def quicksort(array):
    if(array == []):
        return []
    elif(len(array) == 1):
        return array
    else:
        return quicksort(getFunc(array, array[0], lessThan)) + \
            getFunc(array, array[0], equal) + \
            quicksort(getFunc(array, array[0], greaterThan))
 
array = [5, 4, 5, 6, 8, 3, 2, 1, 6]
print(quicksort(array))
 
# OUTPUT
#
# $ python quicksort.py
#   [1, 2, 3, 4, 5, 5, 6, 6, 8]

Now, this code certainly is not as short as “Ahot’s blog”’s version, but hey, I like it!

Oh, and on a side note, this is my first posting using GeSHi, and it works great!

Older Posts »