Zombie Zen

Zombie Zen Blog

A night of fun hacks

Posted

I discovered that some of my code was still living on my old laptop from high school. The laptop hadn’t been booted in about 4 years, so the clock battery had died, causing the filesystem checks to fail (this is Ubuntu 9.10, which cared about these things). I reset the clock manually, boot up the machine, and decide that to be on the safe (but marginally inefficient) side, I’ll copy my entire multi-GB home directory to my more beefy desktop and filter out what I don’t want there.

Sadly, this laptop came before 802.11n and is limited to 54 Mbps. I have an AirPort Express with only one local port, which is connected to my desktop, but I don’t want to disrupt the network setup. I realize I can chain the Ethernet from my old laptop (named metroid) to my new laptop (named roran), which has 802.11n to connect to my desktop (named nasuada).

It's a UNIX system. I know this.

ross@nasuada$ nc -l 8080 > mybackup.tar.bz2
ross@roran$ nc -l 8080 | nc nasuada.local 8080
ross@metroid$ tar -jcf - $HOME | nc roran.local 8080



I love Unix.

Reblog this if you’re older than Google.

Reblogged from rachelomgosh (originally from beautiful-br0ken-b0nes)

come-come-cardinal:

keepcalmandgosurfing:

geekyninja1:

attend-hogwarts:

grrrbarrowman:

skarosoul:

image

It scares me that there’s only 1000 reblogs.

It scares me that there’s only 3000 reblogs.

how old is google?

google is 13 today

image

Particularly fitting, I feel.

Why Go Does Not Need Generics

Posted

(This developed from a thread with some other Cal Poly students discussing Go.)

One of the frequently asked questions about Go is why are there no generics in the language. It’s a fair point from the perspective of other OOP languages, but idiomatic Go code un-asks the question.

First, it is important to understand how interfaces work in Go. The gist is that interfaces use virtual method lookups, but retain the underlying type, so a conversion back to the original type is still type-safe. An empty interface (interface{}) works as a type-safe equivalent of C’s void*: you can put any type inside of an empty-interface variable, and then you can un-box it later.

The simplest way to define a linked list is through the empty interface: interface{}.

type Node struct {
    Value interface{}
    Next *Node
}

And indeed, this is how the container/list package package works, give or take some complexity. However, my argument is that this is the wrong way to do this. It requires an explicit boxing/un-boxing hit for every access, and this is where (I think) most of the call for generics comes from. There’s a much more idiomatic way to do this. My two case studies here are the sort package and the container/heap package from the standard library.

We start with sort, which defines an interface, sort.Interface:

package sort

func Sort(data Interface)

type Interface interface {
    // Len is the number of elements in the collection.
    Len() int
    // Less returns whether the element with index i should sort
    // before the element with index j.
    Less(i, j int) bool
    // Swap swaps the elements with indexes i and j.
    Swap(i, j int)
}

This may not strike you as a generic container, but that is precisely the point. You can — with a bit of boilerplate — create a type that wraps a typed slice that implements sort.Interface. Thus, the algorithm can work on any type and only works uses indices. This is much cheaper than boxing/unboxing on access.

The second example is container/heap:

package heap

func Init(h Interface)
func Pop(h Interface) interface{}
func Push(h Interface, x interface{})
func Remove(h Interface, i int) interface{}

type Interface interface {
    sort.Interface
    Push(x interface{}) // add x as element Len()
    Pop() interface{}   // remove and return element Len() - 1.
}

Admittedly, there is a bit more boxing/un-boxing going on here, but the idea is still similar. We now have a data structure that requires very few box/unbox operations (two per push/pop). It is important to note that this is still type-safe.

You could implement a binary tree structure similarly:

package tree

func Search(root *Node, val interface{}) *Node

type Node struct {
    Index       int
    Left, Right *Node
}

type Interface interface {
    Len() int
    Less(i, j int) bool
    Push(x interface{})
    Pop() interface{}
}

The Search function would push the val interface and use it for comparisons against the values stored in the tree, then pop it once finished. Admittedly, this isn’t the prettiest interface, but it works in a pinch. It works out to be only one box/un-box round-trip.

As we’ve seen, by “flipping” around the algorithms and separating them from the data structures using interfaces, we can still reap the benefits of generic containers from other languages.

ladyinterrobang:

jonjonlewis:

thegirlwithagrapefruit:

inspirezme:

There has been a lot of hype, good and bad about the Google Glass. What can unanimously be confirmed is that it is a bold effort by Google to change the way we do things. This morning Google released their first practical vision for the long awaited Google Glass. Although there has still been no word on when it will be released for consumer use, They have released a new video (see below) along with new images and information to get our technology teeth into. Google have reached out to the communities of Google+ and Twitter to give die hard enthusiasts a chance to use the Google Glass.

“We’re looking for bold, creative individuals who want to join us and be a part of shaping the future of Glass. We’d love to make everyone an Explorer, but we’re starting off a bit smaller. We’re still in the early stages, and while we can’t promise everything will be perfect, we can promise it will be exciting.”

Google have decided that its time to put on your glasses and enter a new dimension of technology, let us know whether you are excited or skeptical about the Google Glass.

Watch the video on Youtube here.

[Images and Video from Google / View more at Google Glass]

This is crazy.

Well, I know what the only thing I’m asking for this Christmas…

SO COOL

but

how do people already wearing glasses wear them?

I do remember hearing at one point that they had a way of clipping onto prescription glasses.

(standard disclaimer that I don’t know anything, this is based on speculation and is not an official statement from Google yada yada…)

I think noetic would get a kick out of this website, if he hasn’t seen it already.

I think noetic would get a kick out of this website, if he hasn’t seen it already.

Posted

So I know I don’t Tumblr all that much, but when I joined Tumblr, blogging was a different ballgame. I still want to keep this blog (zombiezen) about things that I do, but I want to have a fun reblog-y blog blag (blag).

I signed up for another Tumblr: zombieetc. You should follow me there!

stephaniekilbury:


Cried when I read this.
“They told me the big black Lab’s name was Reggie, as I looked at him lying in his pen. The shelter was clean, no-kill, and the people really friendly. I’d only been in the area for six months, but everywhere I went in the small college town, people were welcoming and open. Everyone waves when you pass them on the street.
But something was still missing as I attempted to settle in to my new life here, and I thought a dog couldn’t hurt. Give me someone to talk to. And I had just seen Reggie’s advertisement on the local news. The shelter said they had received numerous calls right after, but they said the people who had come down to see him just didn’t look like “Lab people,” whatever that meant. They must’ve thought I did.But at first, I thought the shelter had misjudged me in giving me Reggie and his things, which consisted of a dog pad, bag of toys almost all of which were brand new tennis balls, his dishes and a sealed letter from his previous owner.See, Reggie and I didn’t really hit it off when we got home. We struggled for two weeks (which is how long the shelter told me to give him to adjust to his new home). Maybe it was the fact that I was trying to adjust, too.Maybe we were too much alike.I saw the sealed envelope. I had completely forgotten about that. “Okay, Reggie,” I said out loud, “let’s see if your previous owner has any advice.”____________ _________ _________ _________To Whomever Gets My Dog:Well, I can’t say that I’m happy you’re reading this, a letter I told the shelter could only be opened by Reggie’s new owner. I’m not even happy writing it. He knew something was different.So let me tell you about my Lab in the hopes that it will help you bond with him and he with you.First, he loves tennis balls. The more the merrier. Sometimes I think he’s part squirrel, the way he hoards them. He usually always has two in his mouth, and he tries to get a third in there. Hasn’t done it yet. Doesn’tmatter where you throw them, he’ll bound after them, so be careful. Don’t do it by any roads.Next, commands. Reggie knows the obvious ones —-“sit,” “stay,” “come,” “heel.”He knows hand signals, too: He knows “ball” and “food” and “bone” and “treat” like nobody’s business.Feeding schedule: twice a day, regular store-bought stuff; the shelter has the brand.He’s up on his shots. Be forewarned: Reggie hates the vet. Good luck getting him in the car. I don’t know how he knows when it’s time to go to the vet, but he knows.Finally, give him some time. It’s only been Reggie and me for his whole life. He’s gone everywhere with me, so please include him on your daily car rides if you can. He sits well in the backseat, and he doesn’t bark or complain. He just loves to be around people, and me most especially.And that’s why I need to share one more bit of info with you…His name’s not Reggie. He’s a smart dog, he’ll get used to it and will respond to it, of that I have no doubt. But I just couldn’t bear to give them his real name. But if someone is reading this … well it means that his new owner should know his real name. His real name is “Tank.” Because, that is what I drive.I told the shelter that they couldn’t make “Reggie” available for adoption until they received word from my company commander. You see, my parents are gone, I have no siblings, no one I could’ve left Tank with .. and it was my only real request of the Army upon my deployment to Iraq, that they make one phone call to the shelter … in the “event” … to tell them that Tank could be put up for adoption. Luckily, my CO is a dog-guy, too, and he knew where my platoon was headed. He said he’d do it personally. And if you’re reading this, then he made good on his word.Tank has been my family for the last six years, almost as long as the Army has been my family. And now I hope and pray that you make him part of your family, too, and that he will adjust and come to love you the same way heloved me.If I have to give up Tank to keep those terrible people from coming to the US I am glad to have done so. He is my example of service and of love. I hope I honored him by my service to my country and comrades.All right, that’s enough. I deploy this evening and have to drop this letter off at the shelter. Maybe I’ll peek in on him and see if he finally got that third tennis ball in his mouth.Good luck with Tank. Give him a good home, and give him an extra kiss goodnight - every night - from me.Thank you,Paul Mallory____________ _________ _________ _______I folded the letter and slipped it back in the envelope. Sure, I had heard of Paul Mallory, everyone in town knew him, even new people like me. Local kid, killed in Iraq a few months ago and posthumously earning the SilverStar when he gave his life to save three buddies. Flags had been at half-mast all summer.I leaned forward in my chair and rested my elbows on my knees, staring at the dog.“Hey, Tank,” I said quietly.The dog’s head whipped up, his ears cocked and his eyes bright.“C’mere boy.”He was instantly on his feet, his nails clicking on the hardwood floor. He sat in front of me, his head tilted, searching for the name he hadn’t heard in months. “Tank,” I whispered.His tail swished.I kept whispering his name, over and over, and each time, his ears lowered, his eyes softened, and his posture relaxed as a wave of contentment just seemed to flood him. I stroked his ears, rubbed his shoulders, buried myface into his scruff and hugged him.“It’s me now, Tank, just you and me. Your old pal gave you to me.” Tank reached up and licked my cheek.“So whatdaya say we play some ball?” His ears perked again.“Yeah? Ball? You like that? Ball?”Tank tore from my hands and disappeared into the next room. And when he came back, he had three tennis balls in his mouth.”

stephaniekilbury:

Cried when I read this.

“They told me the big black Lab’s name was Reggie, as I looked at him lying in his pen. The shelter was clean, no-kill, and the people really friendly. I’d only been in the area for six months, but everywhere I went in the small college town, people were welcoming and open. Everyone waves when you pass them on the street.


But something was still missing as I attempted to settle in to my new life here, and I thought a dog couldn’t hurt. Give me someone to talk to. And I had just seen Reggie’s advertisement on the local news. The shelter said they had received numerous calls right after, but they said the people who had come down to see him just didn’t look like “Lab people,” whatever that meant. They must’ve thought I did.

But at first, I thought the shelter had misjudged me in giving me Reggie and his things, which consisted of a dog pad, bag of toys almost all of which were brand new tennis balls, his dishes and a sealed letter from his previous owner.

See, Reggie and I didn’t really hit it off when we got home. We struggled for two weeks (which is how long the shelter told me to give him to adjust to his new home). Maybe it was the fact that I was trying to adjust, too.
Maybe we were too much alike.

I saw the sealed envelope. I had completely forgotten about that. “Okay, Reggie,” I said out loud, “let’s see if your previous owner has any advice.”
____________ _________ _________ _________

To Whomever Gets My Dog:

Well, I can’t say that I’m happy you’re reading this, a letter I told the shelter could only be opened by Reggie’s new owner. I’m not even happy writing it. He knew something was different.

So let me tell you about my Lab in the hopes that it will help you bond with him and he with you.

First, he loves tennis balls. The more the merrier. Sometimes I think he’s part squirrel, the way he hoards them. He usually always has two in his mouth, and he tries to get a third in there. Hasn’t done it yet. Doesn’t
matter where you throw them, he’ll bound after them, so be careful. Don’t do it by any roads.

Next, commands. Reggie knows the obvious ones —-“sit,” “stay,” “come,” “heel.”

He knows hand signals, too: He knows “ball” and “food” and “bone” and “treat” like nobody’s business.

Feeding schedule: twice a day, regular store-bought stuff; the shelter has the brand.

He’s up on his shots. Be forewarned: Reggie hates the vet. Good luck getting him in the car. I don’t know how he knows when it’s time to go to the vet, but he knows.

Finally, give him some time. It’s only been Reggie and me for his whole life. He’s gone everywhere with me, so please include him on your daily car rides if you can. He sits well in the backseat, and he doesn’t bark or complain. He just loves to be around people, and me most especially.

And that’s why I need to share one more bit of info with you…His name’s not Reggie. He’s a smart dog, he’ll get used to it and will respond to it, of that I have no doubt. But I just couldn’t bear to give them his real name. But if someone is reading this … well it means that his new owner should know his real name. His real name is “Tank.” Because, that is what I drive.

I told the shelter that they couldn’t make “Reggie” available for adoption until they received word from my company commander. You see, my parents are gone, I have no siblings, no one I could’ve left Tank with .. and it was my only real request of the Army upon my deployment to Iraq, that they make one phone call to the shelter … in the “event” … to tell them that Tank could be put up for adoption. Luckily, my CO is a dog-guy, too, and he knew where my platoon was headed. He said he’d do it personally. And if you’re reading this, then he made good on his word.

Tank has been my family for the last six years, almost as long as the Army has been my family. And now I hope and pray that you make him part of your family, too, and that he will adjust and come to love you the same way he
loved me.

If I have to give up Tank to keep those terrible people from coming to the US I am glad to have done so. He is my example of service and of love. I hope I honored him by my service to my country and comrades.

All right, that’s enough. I deploy this evening and have to drop this letter off at the shelter. Maybe I’ll peek in on him and see if he finally got that third tennis ball in his mouth.

Good luck with Tank. Give him a good home, and give him an extra kiss goodnight - every night - from me.

Thank you,

Paul Mallory
____________ _________ _________ _______

I folded the letter and slipped it back in the envelope. Sure, I had heard of Paul Mallory, everyone in town knew him, even new people like me. Local kid, killed in Iraq a few months ago and posthumously earning the Silver
Star when he gave his life to save three buddies. Flags had been at half-mast all summer.

I leaned forward in my chair and rested my elbows on my knees, staring at the dog.

“Hey, Tank,” I said quietly.

The dog’s head whipped up, his ears cocked and his eyes bright.

“C’mere boy.”

He was instantly on his feet, his nails clicking on the hardwood floor. He sat in front of me, his head tilted, searching for the name he hadn’t heard in months. “Tank,” I whispered.

His tail swished.

I kept whispering his name, over and over, and each time, his ears lowered, his eyes softened, and his posture relaxed as a wave of contentment just seemed to flood him. I stroked his ears, rubbed his shoulders, buried my
face into his scruff and hugged him.

“It’s me now, Tank, just you and me. Your old pal gave you to me.” Tank reached up and licked my cheek.

“So whatdaya say we play some ball?” His ears perked again.

“Yeah? Ball? You like that? Ball?”

Tank tore from my hands and disappeared into the next room. And when he came back, he had three tennis balls in his mouth.”