"Shelle of prayers and Ceremonies"

February 18th, 2009 John Van Enk No comments

“Right,” said Om. “Now…listen. Do you know how gods get power?”

“By people believing in them,” said Brutha. “Millions of people believe in you.”

Om hesitated.

All right, all right. We are here and it is now. Sooner or later he’ll find out for himself…

“They don’t believe,” said Om.

“But-”

“It’s happened before,” said the tortoise. “Dozens of times. D’you know Abraxas found the lost city of Ee? Very strange carvings, he says. Belief, he says. Belief shifts. People start out believing in the god and end up believing in the structure.”

“I don’t understand,” said Brutha.

“Let me put it another way,” said the tortoise. “I am your God, right?”

“Yes.”

“And you’ll obey me.”

“Yes.”

“Good. Now take a rock and go and kill Vorbis.”

Brutha didn’t move.

“I’m sure you heard me,” said Om.

“But he’ll…he’s…the Quisition would-”

“Now you know what I mean,” said the tortoise. “You’re more afraid of him than you are of me, now. Abraxas says here: `Around the Godde there forms a Shelle of prayers and Ceremonies and Buildings and Priestes and Authority, until at Last the Godde Dies. Ande this maye notte be noticed.’ “

Terry Pratchett – Small Gods

Categories: Distraction Tags: ,

Happy… UNIX TIME DATE THINGY DAY!

February 13th, 2009 John Van Enk 1 comment

$ while true; do date +%s; sleep 1; done
1234567883
1234567884
1234567885
1234567886
1234567887
1234567888
1234567889
1234567890

Categories: Uncategorized Tags: ,

Scurry: What is it?

February 13th, 2009 John Van Enk No comments

Scurry is a non-trivial piece of software (at least in my mind), but the roll it plays isn’t all that hard to understand. I describe it as a “Resilient P2P VPN,” what does that mean? Well, the VPN part isn’t too hard.

Wikipedia (at least at the time of writing) describes a VPN as:

A virtual private network (VPN) is a computer network in which some of the links between nodes are carried by open connections or virtual circuits in some larger network (e.g., the Internet) as opposed to their conduction across a single private network.

Usually, a VPN is used to access corporate resources from off site (a dial-in VPN which lets you access servers or printers from somewhere other than the office building you work in). In a less professional environment, VPN’s are used to play older video games that don’t support direct internet gameplay. This less professional use was what I originally had in mind when writing Scurry.

The other interesting pieces of Scurry are its resillience and the P2P (peer to peer) nature. There is no single point of failure in Scurry networks and hosts don’t have to access a specific central server to gain access to the network.

We’ll talk about both of these pieces more in the future.

For those interested:

Categories: Scurry Tags: , ,

Distraction: Fun with diagrams!

February 11th, 2009 John Van Enk No comments

I’ve finally sat down and played with Brent Yorgey’s diagrams package. Every once in a while, I just want to write something fun–some feel good code. Well, I had so much fun, I want to describe what I made.

It’s nothing complex or strange, it’s just a few shapes with some colors! (But the colors are so shiny and happy!)

Lets start from the top:

numCols, numRows :: Int
numCols = 23
numRows = 5

Here, we just defined how many shapes wide and how many shapes tall we want our resulting diagram to be. Lets define main next:

main :: IO ()
main = renderAs SVG "out2.svg" (Width width) dgram
    where width = (fromIntegral numCols) * 30

Alright, we know what numCols is, and we see width defined in the where clause, but what is dgram?

dgram :: Diagram
dgram = vcat $ take numRows rows
    where rows = map hcat $ plines crps

dgram is the top level diagram we’re rendering. vcat is a vertical concatenation of several other diagrams. We take a specific number of rows from rows–the horizontal concatenation (hcat) of whatever is generated by plines crps–and concatenate them together vertically.

Alright, we seem to be almost there now. What is plines?

plines :: [Diagram] -> [[Diagram]]
plines [] = []
plines pls = let (l,ls) = splitAt numCols pls
             in l : (plines ls)

As it turns out, plines is just a cheap chunking function with a fixed chunk size. All this does is turn a list into a list of lists with the same length. If the sublists were concatenated back together again, you’d have your original list.

We’ve seen everything plines has to offer, what about crps?

crps :: [Diagram]
crps = zipWith fillColor cs rps
    where rps = zipWith rotate rs ps
          rs = cycle . map (/ 4) $ [1..4]                 -- 4 rotations
          ps = cycle . map (flip regPoly 1) $ [3..7]      -- 5 polygons
          cs = cycle [red,black,green,blue,yellow,violet] -- 6 colors

Hey! This is more interesting! Lets look a little closer at what’s happening here.

The ps symbol defines an infinite list of cycling polygons. We use the regular polygon (regPoly) function to generate polygons with 3, 4, 5, 6, and 7 sides. The cs symbol is just defining an infinite list of colors–nothing too complex here. The rs symbol is a cycling list of 1/4, 2/4, 3/4, and 4/4. These are used as rotations in terms of turns.

Now, what is that rps symbol? Lets see, we are zipping rs and ps together using the function rotate which accepts a Double representing a fraction of a turn and a Diagram to rotate. So, rps is an infinite list of cycling polygons where each successive polygon is rotated one quarter turn more than the previous.

This means that crps is an infinite list of cycling polygons each rotated one quarter turn more than the previous polygon but and each polygon has a cycling fill color! Neat!

So what does this look like?

Colorful cycling rotating polygons!

I don’t know about you, but that takes me back to grade school. Sometimes a little bit of happy code can brighten your day!

Links to source files and SVG images:
Original, not quite as cool, attempt and its SVG rendering.
Finished colorful one and its SVG rendering.

Categories: Distraction Tags: ,

Introduction

January 24th, 2009 John Van Enk No comments

This page will mostly discuss one of my personal projects: a P2P VPN program named Scurry! If I stray from this, don’t be surprised–I’m occasionally shortsighted. ;)

So, without further chatter:

main = putStrLn "Hello World!"
Categories: Scurry Tags: