GitHub broke my scp

March 9th, 2010 vivin No comments

I set up git on my FreeBSD box so that I can commit my code to GitHub. Today I tried to scp some stuff over and I was met with this rather unhelpful message:

vivin@serenity ~/Projects/code
$ scp -r vivin@www.vivin.net:~/code/agnostic .
Password:
ps: Process environment requires procfs(5)
Initializing new SSH agent...

vivin@serenity ~/Projects/code
$

I fixed the procfs problem by adding the following to my /etc/fstab:

proc                    /proc           procfs  rw              0       0
linproc                 /compat/linux/proc      linprocfs       rw      0       0

and then running:

vivin@enterprise ~
$ sudo mount /compat/linux/proc

vivin@enterprise ~
$ sudo mount /proc

So I try to scp again and I get:

vivin@serenity ~/Projects/code
$ scp -r vivin@www.vivin.net:~/code/agnostic .
Password:
Initializing new SSH agent...

vivin@serenity ~/Projects/code
$

WTF? Then I remembered making some changes to my .bashrc to be able to commit to github:

function start_agent {
  echo "Initializing new SSH agent..."
  /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
  echo succeeded
  chmod 600 "${SSH_ENV}"
  . "${SSH_ENV}" > /dev/null
  /usr/bin/ssh-add;
}

# Source SSH settings, if applicable
if [ -f "${SSH_ENV}" ]; then
  . "${SSH_ENV}" > /dev/null
  #ps ${SSH_AGENT_PID} doesn't work under cywgin
  ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
    start_agent;
  }
else
  start_agent;
fi

I pulled all that out of my .bashrc and made a separate shell script for it. After I did that, scp started working again. I had no idea that calling scp would actually run .bashrc

CherryBlossom

March 4th, 2010 vivin No comments

I’ve created a project page for the CherryBlossom programming language. You can check it out here. The interpreter is written in perl.

Introducing CherryBlossom

March 2nd, 2010 vivin No comments

Over the past month, I’ve been working on a new project. It’s called CherryBlossom, and it’s a way to write programs using haikus. Strictly speaking, CherryBlossom is a brainfuck analog. I actually spent more time writing the obligatory “Hello World” program in CherryBlossom than I did writing the interpreter for the language. The idea behind CherryBlossom is simple. Brainfuck instructions are mapped to words that convey the essence of the Brainfuck instruction. Of course, this is a little subjective and also a little abstract.

Ultimately, it serves as a way to make program code not just functional, but beautiful and artistic. Thus, we introduce a new criteria to programming. Your code must not only be elegant algorithmically, but must also be poetic and artistic (also, since program code consists of haikus, you need to represent your code in sets of 3 lines with the first and last lines having 5 syllables, and the second line 7. That is, conforming to haiku rules). CherryBlossom serves to blend the programmer and the poet into one entity (hopefully with amazing results).

Here is an example of “Hello World!” in CherryBlossom. I have opted to use a spruced up div tag instead of enclosing my beautiful poem in soulless sourcecode tags.
Read more…

Maven project for Generic (n-ary) Tree in Java

March 2nd, 2010 vivin No comments

Guus was kind enough to make a maven project for the Generic Tree. He also fixed an error in my equals method for the GenericTreeNode (I intended to do Object.equals(Object obj) but was doing GenericTreeNode.equals(GenericTreeNode obj). Since it’s a maven project, you can easily create a jar out of it and add it as a dependency to your project. You can download the project here. Thanks Guus!

Generic (n-ary) Tree in Java

January 30th, 2010 vivin 8 comments

Last week I was solving a problem at work that required the use of a Generic (n-ary) Tree. An n-ary tree is a tree where node can have between 0 and n children. There is a special case of n-ary trees where each node can have at most n nodes (k-ary tree). This implementation focuses on the most general case, where any node can have between 0 and n children. Java doesn’t have a Tree or Tree Node data structure. I couldn’t find any third-party implementations either (like in commons-lang). So I decided to write my own.
Read more…

A brainfuck interpreter in bAdkOde

January 23rd, 2010 vivin 3 comments

A few days before I left India, I started writing a brainfuck interpreter in bAdkOde. I finished implemented all the instructions, excepting for looping. I actually finished the code (and fixed all bugs) while I was in the air, flying from Dubai to Los Angeles. Emirates Airlines has power-plugs for your laptop on the seat. It’s pretty sweet!

An interesting thing I noticed was that I couldn’t perfectly emulate the input instruction. I’m feeding the brainfuck code to the interpreter from STDIN and so that might be the problem. I’ve noticed that brainfuck interpreters written in brainfuck have the same problem. You have to specify program input before hand. This is what I’ve decided to do. You write brainfuck code, and then mark the end of program code by an exclamation mark. After the exclamation mark, you provide any input, and then mark the end of input by another exclamation mark. Programs that do not have any input end with two exclamation marks. After I finished writing the interpreter, I commented it. While I was doing this, I noticed a lack of labels in bAdkOde. So, I decided to update the interpreter to include them. Speaking of which, I really ought to rewrite the interpreter sometime…

Anyway, here is the code to the interpreter. I’m providing a link to it, because the commented version is rather large. But here’s the expanded (without labels or macros), unformatted version:

>3a>1b{!b?b>b[a)b-91b{=b+1[b>1b}+91b-93b{=b-1[b>1b}+93b(b+1a-33b}>0[a+1a>2b>a[b>1b{!b?b>b[a+1a-33b}>1b>a[b>0a>[aa>ab{=a>1a>[ab>3a{![a)a>[aa-62a{=a+1b-30000b)a>ba{+b>1b>[bb)b>0b-1b>0a}{-a+30000b)b>0a}(b(a+62a}+62a-60a{=a-1b)a>1a>[aa-ab>ba{-b>1a>[aa+30000a>ab)b>0b>0a-1a}{+a>1a>[aa+ab)b>0a-1a}(b(a+60a}+60a-43a{=a+1[b+43a}+43a-45a{=a-1[b+45a}+45a-46a{=a"[b+46a}+46a-44a{=a)a>2a>[aa>[a[b>2a+1[a(a+44a}+44a-91a{=a(a)b)a>[bb{=b>0b>1[b{![b(a+1a)a>[aa)a-91a{=a+1[a>1a}+91a-93a{=a-1[a>1a}+93a(a}(a-1a)a>1b}(a(b)a+91a}+91a-93a{=a(a)b)a>[bb{!b>0b>0[b-1[b{![b(a-1a)a>[aa)a-91a{=a+1[a>1a}+91a-93a{=a-1[a>1a}+93a(a}>0b}(a(b)a+93a}+93a(a+1a}>1a>0b}{!b"85"110"109"97"116"99"104"101"100"32"98"114"97"99"107"101"116"115>0b}

Also, this is additional proof for Turing Completeness. Yes, I’m a nerd! :)

Happy New Year

December 31st, 2009 vivin No comments

Happy New Year! Well, this year is already starting off pretty well because of:

Aparna

Aparna

I wonder what this decade (alright, I know it technically starts in 2011, but still) is going to be like. I hope there’s better music for one. At any rate, a whole set of new experiences and new memories; the last one wasn’t short on that! Here’s to another great decade!

Note: This post shows up on December 31st because it isn’t New Year’s yet in Arizona (and this blog runs on MST)! I’m in India right now and it’s January 1st, 2010 here.

Glenn Beck is an asshole

December 29th, 2009 vivin 9 comments

…within the span of a few minutes, Beck implied that there are no quality medical schools in India; implied that medical care in India is a shoddy imitation of real health care; implied that the entire nation is an undeveloped backwater without even so much as indoor plumbing; and compared the Ganges River, a holy body of water for one of the world’s oldest and largest religions, to a disease…

I guess the only reason Glenn Beck is popular is because there is apparently a marketable-segment of idiots in America. You know, the morons that watch Fox News and actually believe what they hear. Glenn Beck, you are an asshole. You are an ignorant bigot and a douchebag. There are a few people that I know, that oppose the health reform. But the strange thing is that they have rather valid arguments, and even though I may not agree with them, I find them rather intelligent and well thought-out. I mean, Mr. Beck. I realize that by being an ignorant douchebag it’s beyond you to form coherent arguments but seriously… do you have to stoop to the level of offending an entire nation? Or what about the entire community of Indian-Americans?

Usually when people make arguments or counter-arguments about a topic, they usually know what they’re talking about because they’ve researched the topic thoroughly. Oh wait. That’s only if they have a proper show that actually discusses political topics with valid arguments instead of gleefully bending over for the lunatic far-right and being their sockpuppet. Hell, I probably shouldn’t blame you. You are making money after all, even if you have to sell your soul for it. No, your show is a circus and your arguments are bullshit. Even still, I find it appalling that you would denigrate an entire nation and community. You may not think much about Indian doctors, but they seem to be a successful and well-respected bunch in India, with a large number of satisfied customers. In one fell swoop you’ve insulted the cultural and religious sentiments of Indians, you’ve made light of the sweat, blood, and tears of her doctors that strive to serve their nation (and who have migrated to other nations, including *gasp* the United States and serve Americans), and you’ve implied that India is some backwater country without any sort of facilities. Sure, India is no United States and it has a long way to go, and even though you may have the right to say whatever the hell you want, it’s really, really bad form to make fun of a country and her people. You xenophobic, ignorant, douchebag. I find it surprising that even you would stoop this low for ratings.

You sir, are an asshole.

She Said Yes

December 27th, 2009 vivin 3 comments

Yes

She said, “Yes”. Although I guess it was never in doubt that she would say anything else (being a semi-arranged marriage and all), it still feels nice :) . The official engagement ceremony was today. It was a traditional Nair engagement ceremony (known as a nischayam – literally translated, “decision”) where both families express their consent to the alliance and inform everyone in attendance of the same. I don’t have pictures of the ceremony on me; I’m waiting on the CD of photos from the photographers. This picture is from when I first gave her the ring.

bAdkOde is Turing Complete

December 26th, 2009 vivin 2 comments

In my previous post, I suggested that bAdkOde might be Turing Complete by writing a quine. One of the ways to actually prove Turing Completeness is to try and write an interpreter for another Turing-Complete language in bAdkOde. Another approach involves providing a direct translation from another Turing-Complete language into bAdkOde. Here, I prove the Turing Completeness of bAdkOde by providing a direct translation from Brainfuck into bAdkOde.
Read more…