Wednesday, May 21, 2014

Learning Virtualenv in Python

Good references:
1. http://simononsoftware.com/virtualenv-tutorial/
2. http://iamzed.com/2009/05/07/a-primer-on-virtualenv/

about virtualenvwrapper:
http://blog.fruiapps.com/2012/06/An-introductory-tutorial-to-python-virtualenv-and-virtualenvwrapper

Wednesday, May 7, 2014

Eclipse: Syntax Error, parameterized types are only if source level is 1.5

When I developed my Java application, the following error occured:
Syntax Error, parameterized types are only if source level is 1.5 blabla

After digging around in Google, it seems that we have to change the default configuration of Java compiler for our project. It has been discussed in StackOverflow.com, and I found that post from VigneshKumar S precisely answered my problem.

So, what should we do? here what he says

  1. Go to project properties
  2. Then 'Java Compiler' -> Check the box ('Enable project specific settings')
  3. If 'use compliance from execution blabla' is checked, uncheck it first. Then, check the 'use default compliance settings'
  4. Change the compiler compliance level to '5.0' & click OK.
  5. Rebuild your project
Then, the error will disappear.

Tuesday, November 26, 2013

Automatically Select Fastest Servers for apt in Ubuntu

Using GUI-based Ubuntu, it is very easy to select the fastest (or change, in general) mirror servers for apt purposes. All you need to do is just select  System|Administration|Software Sources.

But things get ugly if you want to do it on command-line. You have to update sources.lists manually. That is a tiresome job, and not cool either :D

Well, other people have thought about the same problem and they have been working solutions for this. There is a package named after netselect-apt. It allows you to update the fastest apt server automatically, via command-line.

But, there is another way, and it is easier. All you have to do is adding these lines at the top of your sources.list (assuming you are using Ubuntu 12.04):

deb mirror://mirrors.ubuntu.com/mirrors.txt precise main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt precise-updates main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt precise-backports main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt precise-security main restricted universe multiverse


That is it. You need to perform 'apt-get update' first, and then 'apt-get upgrade'. Notice that the server used is the fastest one (relative to your location).

Wednesday, November 13, 2013

Named: error (broken trust chain)

My DNS server keeps complaining similar to this:
error (broken trust chain) resolving '0.ubuntu.pool.ntp.org/AAAA/IN': 208.67.220.220#53
Having researched on Google, many people suggested that the problem lies on the time accuracy. Therefore, we need to update the clock.

I had updated my system using ntpdate. But bind9 error logs didn't change.

After taking few times tinkering about his weird problem, I was stumbled upon a mailing list discussion about dnssec. It was an old discussion. There was a bug in the bind version (then) which produced similar error output if configured as forwarder.

I immediately changed my named.conf.options, from the following:
dnssec-enable yes;
dnssec-validation yes;
dnssec-lookaside auto;

to this one:
dnssec-enable no;
dnssec-validation no;

after I restarted the bind9 service (I am using Ubuntu 12.04):
service bind9 restart

finally, business went normal again!

I haven't dug deep about this issue. Once I figure out the problem, I'll update this post.

Monday, May 2, 2011

Scapy Installation

The easiest way to install and keep updates of scapy is by using mercurial. I prefer to use Ubuntu, rather than Windows, because I don't want to keep thinking about compability things and all other unnecessary stuff to think about. Just to keep my mind focused.

Okay, here is how it is done:
Install mercurial
#apt-get install mercurial
Check out a clone of Scapy’s repository. Here, you'll get the latest development version of it.
# hg clone http://hg.secdev.org/scapy
It will create a new directory named after 'scapy'. Here, all scapy codes are copied. You can either install it to your system (enter to this directory, run 'sudo python setup.py install') or run it directly (using run_scapy.bat).
To keep update with the latest contribution, use the following step:
# hg pull
# hg update
Then, install/run run_scapy as usual.

Monday, April 11, 2011

XmlNodeType Members

Enumeration XmlNodeType (namespace: System.Xml) is used to specify the types of XML node.
 
XmlNodeType members:
  • None  --> This is returned by the XmlReader if a Read method has not been called.
  • Element  --> An element (for example, ).
  • Attribute --> An attribute (for example, id='123' ).
  • Text  --> The text content of a node.
  • CDATA --> A CDATA section (for example, )
  • EntityReference --> A reference to an entity (for example, # ).
  • Entity  --> An entity declaration (for example, ).
  • ProcessingInstruction --> A processing instruction (for example, )
  • Comment  --> A comment (for example, )
  • Document  --> A document object that, as the root of the document tree, provides access to the entire XML document.
  • DocumentType --> for example,
  • Notation  --> for example,
  • Whitespace  --> White space between markup
  • SignificantWhitespace  --> White space between markup in a mixed content model or white space within the xml:space="preserve" scope
  • EndElement  --> for example,
  • EndEntity 
  • XmlDeclaration  --> for example,               
dd

Tuesday, April 5, 2011

Check IP Address Type

Idea:
- display all IP addresses
- inspect it one by one, whether:
  - it is IPv4
  - it is IPv6
     - it is loopback address
     - it is link local
     - it is multicast
     - it is site local
     - it is teredo

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;

namespace ConsoleCekIPSatuSatu
{
    class Program
    {
        static IPAddress[] GetIPAddress(string host)
        {
            IPHostEntry hostInfo;
            hostInfo = Dns.GetHostEntry(host);
            return hostInfo.AddressList;
        }

        static void CheckIPType(IPAddress ip)
        {
            if (ip.AddressFamily == AddressFamily.InterNetwork)
            {
                Console.WriteLine("\t\tThis is IPv4");
                CheckIPv4(ip);
            }
            else
            {
                Console.WriteLine("\t\tThis is IPv6");
                CheckIPv6(ip);
            }
        }

        static void CheckIPv4(IPAddress ip)
        {
            // check whether it is loopback address or not
            if (IPAddress.IsLoopback(ip))
                Console.WriteLine("\t\tThis is IPv4 loopback address");
        }

        static void CheckIPv6(IPAddress ip)
        {
            // check whether it is loopback address or not
            if (IPAddress.IsLoopback(ip))
                Console.WriteLine("\t\tThis is IPv6 loopback address");

            // check whether it is link local address
            if (ip.IsIPv6LinkLocal)
                Console.WriteLine("\t\tThis is link local address");
            
            // check whether it is multicast address
            if(ip.IsIPv6Multicast)
                Console.WriteLine("\t\tThis is multicast address");

            // check whether it is site local address
            if (ip.IsIPv6SiteLocal)
                Console.WriteLine("\t\tThis is site local address");

            // check whether it is teredo address
            if (ip.IsIPv6Teredo)
                Console.WriteLine("\t\tThis is teredo address");

        }

        static void Main(string[] args)
        {
            string hostName = Dns.GetHostName();
            Console.WriteLine("Hostname: {0}", hostName);

            // get the IP addresses list
            IPAddress[] hostNameIPAddresses;
            hostNameIPAddresses = GetIPAddress(hostName);

            // check the type of each IP address
            foreach (IPAddress ip in hostNameIPAddresses)
            {
                Console.WriteLine("\n\t" + ip.ToString());
                CheckIPType(ip);
            }

            Console.ReadKey();
        }
    }
}