See also: Heapify

Pages: 1 2 3 4 5 6

Twitter Integration

NEVERFEAR.org is now integrated into Twitter. We've had a Twitter account for sometime that is linked to our IRC channel. Now all article posts are tweeted on publish too!

You can follow us at @NeverfearOrg

...

Read more

There are no comments on this post.

How to convert infix to postfix (Python)

I wrote this originally some time ago. Mostly for my own amusement. It converts from infix to postfix notation.

I expect most of our readers know what these are but for the benefits of completeness infix is a functional notation we humans use for instance in mathematics where the operator sits in between the operands. Example:

(8 * 5) / 4

...

Read more

There are no comments on this post.

How to build a string representation of an integer in any base without bitwise operators

Last week I gave the geeks at #neverfear IRC a coding task, something I've been trying lately to both challenge them and myself. The challenge I gave them was actually a real-life problem I'd faced in industry as a developer. The challenge was as follows.

Produce an algorithm in the language of your choice that recursively converts a numerical value to a hexidecimal string without bitwise operators. Bonus points awarded for generalising your algorithm to the nth base.

We had a few good solutions mostly following a similiar approach in various languages that I'd like to share.

...

Read more

There are no comments on this post.

BandsInTownPy released

A Python module on the API at bandsintown.com released and is available for download at http://github.com/kay/BandsInTownPy

Sample usage:

from bandsintown import *
site = BandsInTownRequest()
 
print "Getting Flyleaf information by name"
artist = site.GetArtistByName("Flyleaf")
print artist.get_as_string().encode('utf-8')
print
 
print "Getting events for Flyleaf by Artist object"
events = artist.GetEvents()
 
print len(events), "events"
 
for event in events:
    print (event)
print
 
print "Getting todays events"
events = site.GetEventsToday()
 
print len(events), "events today"
 
for event in events:
    print event.get_as_string().encode('utf-8')
print
 
print "Getting events for Exilia by name"
events = site.GetEventsByArtistName("Exilia")
 
print len(events), "events"
 
for event in events:
    print event.get_as_string().encode('utf-8')
print

...

Read more

There are no comments on this post.

How many characters should you allocate for a string representation of any given integer in any given base

Once every while somebody asks how to calculate how many characters to allocate when building a string representation of an integer. This is actually a very easy problem.. when you know your maths.

The answer is simply to use logarithms!

floor(log10(number) + 1)

...

Read more

There are no comments on this post.

A caffine induced sense of humour? I surely hope not

Super serial!

import java.io.PrintWriter;
import java.io.Serializable;    
class Doug implements Serializable {
  public Doug(PrintWriter out) {
    out.println(getMood());
  }
  private static String getMood() {
    return ":-(";
  }
}
/*
 * __        ___   ___   __  ____   ___
 * \ \      / / | | \ \ / / / ___| / _ \
 *  \ \ /\ / /| |_| |\ V /  \___ \| | | |
 *   \ V  V / |  _  | | |    ___) | |_| |
 *    \_/\_/  |_| |_| |_|   |____/ \___/
 *
 *  ____  _____ ____  ___    _    _    ___
 * / ___|| ____|  _ \|_ _|  / \  | |  |__ \
 * \___ \|  _| | |_) || |  / _ \ | |    / /
 *  ___) | |___|  _ < | | / ___ \| |___|_|
 * |____/|_____|_| \_\___/_/   \_\_____(_)
 */

...

Read more

There are no comments on this post.

A Java WHOIS protocol implementation

This should all be quite self explanatory. I can't remember why I went ahead and implemented this in Java. I think I was just rusty and wanted some practice. What follows is an implementation of the WHOIS protocol used to get information about a record name (in this case specifically domain name records). The nature of the information is contact information, ownership rights, etc.

The full source code and documentation can be downloaded here. This includes the source package and documentation. Depends only on Java core packages (java.io, java.net, and java.util).

Let's start with the whois server pool (WhoisServerPool.java). This is a static map of top level domain names to the whois server that is responsible for maintaining information on domains with that top level domain name.

...

Read more

There are 6 comments on this post.

Chained hashing implementation

This is my implementation of chained hashing using the hashlittle hash function from Robert Jenkins. This code is meant for educational purposes but should be good enough for normal use (if it's not, I would love to hear your constructive critism!). I have no doubt there are more optimised implementations out there.

Check it out on its project page

...

Read more

There are no comments on this post.

Lewis wins the first match of the neverfear corewar league

Our good friend Lewis (aka Nemmy) can hang his head high today as he won the first round of the neverfear corewar league (http://corewars.neverfear.org/) with his warrior "SourKraut" when it kicked the ass of my warrior, Sanguinity. I'll get you next time!

There are no comments on this post.

Setting up synergy auto-start securely

Synergy is a popular application for sharing a keyboard and mouse between multiple computers on multiple operating systems using your network. One of it's biggest flaws is that the underlying protocol is unencrypted. This means that people could potentially read what you type remotely. This article describes a method for setting up an encryption layer for Unix-like and Windows machines as well as automatically starting Synergy on system boot-up without user-prompts.

While I have no doubt there are several articles on this subject elsewhere, I'm going to give you a walk through from my point of view about how you can set up synergy across multiple Windows and Unix-like systems securely.

This walk through will be divided into two parts. First will be Unix-like setup and the second part will be Windows setup.

...

Read more

There is 1 comment on this post.

Pages: 1 2 3 4 5 6

RSS
Powered by Debian, Guinness, and excessive quantities of caffeine and sugar.