Monthly Archives: June 2013

Integers and Strings in JavaScript

Joe and I just spent an hour or so debugging my Node.js application, a simple multiplayer tag game. The problem was that while a player was moving, they disappeared from every other player’s view. Not the greatest for playability.

So we dove in to the code, and figured out that on each loop, the x and y of each player object looked something like this (x,y):

(299, 445)

then

(2991.3423, 445)

then

(2991.34231.3423, 445)

etc.

So, each time the main game went along, “1.3423” got appended to the x and y variables. We were adding the velocityX and velocityY components to the x and y respectively, so they were somehow getting concatenated instead of added.

It turns out I was doing the following:

Client:

GET(
    'loop/' + currentPlayer.id + "/" + currentPlayer.x + "/" + currentPlayer.y + "/" + currentPlayer.vx + "/" + currentPlayer.vy + "/" + currentPlayer.keyx + "/" + currentPlayer.keyy, function(data){
    hasReturned = true;
    updateData = JSON.parse(data);
});

Server:

requrl = req.url.split('/');
requrl.shift();
currentPlayer.updateLocation(currentWorld, requrl[2], requrl[3], requrl[4], requrl[5], requrl[6], requrl[7]); //world, x, y, vx, vy, keyx, keyy

The problem with this is that each of the variables come back as strings, not integers. So when we call the updateLocation method, we’re passing in strings. Observe:

"1" + "1" // "11"
1 + "1" // "11"
"1" - "1" // 0
"30" * 1 //30
parseFloat("1.234") + 3 // 4.234

So: remember that your URL variables in node are going to come in as strings and not ints or floats, and that if you try to add them to anything, it’ll end up as a concatenation operation.

Hope this saves someone some time someday.

From Manhattan,
— Erty

Blaggregator/WordPress: Aggregating only certain posts

For users of Blaggregator:

If you use wordpress for your blog, you can get a custom feed of only posts which match a tag by constructing the following URL:

http://example.com/?tag=tagname&feed=rss2

So for example, I’m going to tag all of the posts that I want on Blaggregator with “blaggregator” and then give Blaggregator the feed url

http://organicdonut.com/?tag=blaggregator&feed=rss2

so that only certain posts will show up!

This is important because I am keeping a travel blog every day that I’m at Hacker School, including weekends, and I would end up flooding the service with nontechnical posts.

Of course, if you want to read my daily rantings, you can just visit http://organicdonut.com!

From Manhattan,

–Erty

HS Day 13: Two Weird Things and One Fun Thing

So I forgot to mention – there’s a very small window in the kitchen that I opened last night to let some air get through the apartment. Across the way, there’s a window that opens into another apartment – they are about 3 feet apart.

Apparently, the tenant who lives there likes to lean out the window and talk, sing, and yell sometimes. He has a soothing, low, spanish-tinted voice while he’s talking or singing, and I haven’t heard him yelling, but apparently he freaked Levi out one night by shouting into the alley. He doesn’t seem to be dangerous or particularly angry or anything, he just likes to talk into the alleyway.

The other weird thing happened this morning, and this one has actually bothered me, although I think I handled it alright. A guy sitting a chair or two down on the subway started chatting with me this morning. It was a fine conversation and quite friendly, but something about it put me off – he was being too friendly. He was a larger guy, with a beard, and looked fine and trustworthy, but there was something odd about just how open he was during the conversation. We chatted about New York, and he asked how my stay was so far, and inquired about what I was up to in the city; all fine. But he asked for my number twice (I refused), and invited me to tour the city with him (also  refused). I told him straight up that I wasn’t comfortable sharing that with a stranger, but when he tried to get my number twice it really set off the alarm bells.

I can’t tell if he was just gay and hitting on me – there’s no problem with that – but there was a certain element of what can only be described as “stranger danger”. I turned him away without any personal information except a broad sense that I lived in Brooklyn. Thinking back on it now, I mentioned that I was attending Hacker School, which could be dangerous. Best and most likely case, I never see him again. New York is a big city.

The whole thing has been bothering me all day. I’m the kind of scared that makes me want to carry some sort of defense item (can of pepper spray?) on the subway now. Maybe it’s good that I had this encounter and nothing happened, so that I’ll have the proper amount of respect and fear for a situation like this that happens in the future. I’m sad that I’m going to be more wary with random encounters in the future.

I set aside Budgeted this morning and spent all day working on the One Fun Thing, which is Wander, a tag game I’m building in node.js and a pure javascript frontend. I’m excited to say that it’s mostly done and should be ready to show off during the presentations tomorrow. I also might make a zombie mode, but I’ll do that after I get the tag mode working totally.

I’m at Hacker School right now just surfing the internet and watching WCS SC2 – the internet here is a lot better than at my apartment.

From Manhattan,

–Erty

Stop... and go?

Stop… and go?

Spending my time at Hacker School wisely. (This is after hours.)

Spending my time at Hacker School wisely. (This is after hours.)

Post only bulls

Post only bulls

HS Day 12: Moved In

Not a particularly difficult day today. Woke up around 9am with the intention of being on the bus by 9:45. Showered, dressed, and made my way out the door a little ahead of schedule. The bus stop that I have to walk to is just about two blocks from the apartment, and there are a lot of little cafes on the way, so if I manage to get out of bed earlier tomorrow, I might go and have breakfast at one of them. I’m living in the Park Slope neighborhood, which seems to be a pretty trendy part of Brooklyn.

Spent a little while cleaning up my room this morning, just to get things out of Nathaniel’s way. Everyone here seems super chill but I’d like to be a good roommate anyway.

Took the R into Manhattan and walked a half mile to Hacker School, which is quite a bit farther than I’ve been walking. The walk is pleasant, though; up Canal St. and over on Varick St.. Started the day pairing with Rob, who helped me out a lot – I was stuck trying to use Javascript’s map() function on an associative array/object, which apparently isn’t something you can do. Worked on Budgeted for a while before doing a code review with Sam, who had written the game of Set in python. It was well done, except for a few redundancies, some dead code, and an O(n3) function that got called a lot. But we worked through it, and, after some problems with Git while trying to merge – which Alan graciously helped us with – I think we both had a good and very educational experience.

About three people borrowed my cell phone charger today. Apparently it was a popular day to have a dead battery? Good thing I carry a charger with me everywhere.

Amandine and I met with Yael, who I think is a Hacker School alum, this morning. Yael had purchased extra tickets to see The Postal Service this Friday at Barclay center, so Amandine and I bought the tickets off of her. No idea where the seats are, but I’m still excited to see The Postal Service, even with someone I don’t know very well; it will be a good opportunity to make a friend.

After lunch in the park (Sandwiches and wraps from Pret) with Sam, Jimmy, and Mary, and some more coding, about 40 of us attended a talk on jobs after Hacker School. The focus was basically on not getting a job until the end of Hacker School, so that we can focus on programming.

This reminds me that I need to make Scott a résumé.

Stayed a bit late at Hacker School to derp around and watch the WCS StarCraft 2 tournament. Took the R home around 9.

Looking forward to actually getting started on the main guts of Budgeted tomorrow.

From Brooklyn,

–Erty

 

HS Day 11: Long Day of Travel

This morning I departed from the hotel I forgot to mention in my last blog post, after saying an all-too-short goodbye to my family and especially Greta. My dad drove me to the Appleton airport where I boarded a plane for Detroit. An hour of air time later, I was in Detroit. A rushed half hour layover in Detroit later, I was on my way to Newark. A 1.75 hour flight later, I was waiting for a train in New Jersey. Then a train ride, subway ride, another subway ride, and two taxi rides later (I got lost), I was finally at my apartment… for an hour.

The apartment is nice but small, and has only one drawback which is the oppressive heat that pervades its thin walls. It was too hot to stay in today (I’m sitting in a sports bar down the street drinking a malibu and coke to beat the heat) but that was when it was rainy and cool outdoors. I can’t imagine how hot it will get when it’s even too hot outside. We’re looking into an air conditioner.

There are three roommates: Nathaniel, who I’ve never seen with his shirt on, who is attending acting school with another roommate and friend of mine from Colorado, Levi. They’re both in their second year. Imogen has the room at the other end of the hall which will be mine in a month when she moves out; she is British, and originally from a British island. Now from London, she was in New York for an internship but has run out of money and has to return to her homeland. They’re all very nice and very laid back, although I have yet to spend any significant length of time in the apartment.

I unpacked a bit but was immediately out the door again to the eBay offices in Manhattan, for a technical presentation by Lindsey, this week’s hacker-in-residence at Hacker School. She’s getting a Ph.D. in programming languages (as far as I can tell) and had a very cool talk that explained a lot about concurrency that I had been wondering for a while. She lost some of the less computer-scientist traditional-training people in the crowd, but I found it very enjoyable and interesting, despite some major sound problems at the beginning.

I have now pooped at eBay.

ebay offices!

I had been traveling for about 12 hours at that point and decided to leave a bit early – I was disheveled and had tried unsuccessfully to slick my hair back so I just looked like a mess and left. Caught the N followed by the R to get home, then realized the apartment was too hot to work in and came here.

Looking forward to lying down.

From Brooklyn,

–Erty Seidel

HS Day 10: Graduation and Engagement

When June 9th was over, I was a different man.

Let’s start at the beginning:

I woke up and packed my room for a bit, before meeting up with some friends on the first floor of Gaming House to get into our robes and figure out where were needed to go. Greta was awesome and steamed all of our gowns so that they weren’t wrinkly. Graduation day!

We made our way over to the sidewalk along the side of the chapel and lined up; it was a bit cloudy and threatened to rain, but held for the entire day. A very enthusiastic photographer pulled us all out of order to get a group shot. I can’t imagine the picture was very good – he was holding the camera very shakily, at the top of a ladder in cloudy light. We re-lined up and surprisingly on time, walked across the blocked-off street, to thunderous applause.

The professors had lined up along the sides, and behind them stood all of the families and friends. Greta’s family – including Gigi and Jim – drove down for the ceremony. It was an excellent graduation – the speaker was firm, liberal, and funny. At one point, talking about how we need to save the liberal arts, mentioned that English majors had 8 points less of unemployment than Computer Science majors. Fortunately, I have both!

We stood, turned our tassels, and walked across the stage. I had asked for them to put me as Erik “Erty” Seidel, but they called me Erik. Ah well. They probably thought I was trying to prank them or something.

After the ceremony I wandered around shaking hands and thanking professors. I want to send Prof. Gregg a thank-you basket for being so great to me and personally tutoring me in Theory of Computation so that I could graduate.

Took a picture with the Math department, and made sure to find the English department shake hands with Profs. Spurgin and Bond. I found Julian over there and spent some time chatting with him and his family, waiting in line to shake hands with Prof. McGlynn, my creative writing professor.

Found my way back to Gaming House eventually, and stood out front for at least half an hour taking various pictures.

Cleaned and packed for a few hours. Julian had mentioned a few months ago that having to leave right after graduation seemed somewhat rushed – Lawrence required us to be off campus the same afternoon as graduation. It’s a policy that makes sense, but we decided to live by “you don’t have to go home but you can’t stay here” and rent out the English Room at Stone Cellar Brewpub in Appleton, and hold an after-graduation party for seniors.

My family and I almost arrived late, since we were packing right up until when we had to leave. The party went very well – good friends, good food. Then this:


(Click here to watch the video if it doesn’t embed properly.)

I’m very proud to say that I’m now engaged to Greta Dohl. I love her, and although we’ll be apart for a while, I’m glad to have made that commitment before I left. I think the video speaks for itself, so I won’t say much on the topic. We hung out at the party for a few more hours to chat and take pictures.

Soon-to-be-family.

Soon-to-be-family.

She and I spent a while lounging on the side of the pool and talking about the future, then went to bed.

From New York City,

Erty Seidel

HS Days 8 & 9: Back to Appleton

I’m grouping these days for two reasons: One, I’m writing about them on the 10th, so my memory of the days might be a bit weak, and Two: the 9th is really the day to read about, so you might as well skip there now.

I flew out to Hacker School before I graduated from college, with the plan to fly back to Appleton on the 7th for commencement, which I did: my flight had a 3.5 hour layover in Detroit, which I spent surprisingly awake for how much sleep I got the previous night.

The feeling of arriving in Appleton after living in New York City was similar to returning home, but somehow less exciting. I’ve only spent 6 days in the city, but I can tell why so many millions of people live there – it’s invigorating and always active. The last time I was in NYC, I was 9, and the city was terrifying. I have a distinct memory of picking up my sister and dad from a McDonalds at night, and it must have been under and interchange, because I remember not being able to see the sky. I’m beginning to have an appreciation for both the relaxed Midwestern life as well as the hectic city life. I’m glad I lived near San Francisco last summer – it was a good introduction to city living and I don’t think I’d be this comfortable in a metropolis without that experience. Seeing the farms’ squares across the earth relaxed – and at the same time, bored – me.

I arrived in Appleton around 5, and was picked up by Greta and Chelsea at the airport, with Aaron and Gus in the back. We made our way to Jacob’s house in Oshkosh for his graduation (and birthday?) party. There was a bouncy castle, and we spent a large chunk of our time wrestling, bouncing, and experimenting with physics. We played a bit of croquet (I think Aaron won, barely), and ate Chinese food. It was a very enjoyable afternoon – sipping beer with friends in a backyard. I commented to Greta at one point that it was a particularly Midwestern day.

There was also a tire swing.

There was also a tire swing.

After the party we returned to Lawrence and packed up a bit. Hung out with Evan and Jacob until 2:30am.

Woke up on Saturday, packed up a bit, and met my family: Mom, dad, sister, and four of my aunts and uncles. We ate at the graduation picnic under an enormous tent on Main Hall green. Greta joined us for the end, and afterward we took a short tour of Lawrence’s campus: the chapel, Briggs hall, Wriston, Warch, Gaming House.
We spent some time packing up my room and the house, and rented a U-Haul to get all of my stuff home – I have too much of it.

That night was spent cleaning the kitchen and getting the house ready for Summer. Played some smash brothers with Julian and Evan before going to bed.

From New York City,

–Erty Seidel

HS Day 7: Lazy, Presentation

Woke up around 11am this morning – very late, but the nice thing about Hacker School is that nobody gets upset if you don’t come in during the right hours. We have 24hr access to the space, so it’s totally fine to show up late and stay late. Or show up late and leave early. It’s entirely self-directed. I had been getting a sore throat over the last few days and sleeping in seemed to really help with that, so I think in the long run it was a good decision.

Took the train in (bought some fruit snacks off a street vendor and got a Chipotle burrito) and noodled around with React for a few hours. Ran in to a lot of weird problems, but there’s not much documentation on this. I’d love to find a real React expert and pair program with them for just a moment, or have them review my code. Maybe I’ll put out a call on the internet next week. It’s just going really slowly because I don’t feel like I have a good grip on the libarary, and there aren’t any people at the school who know anything about it. Monday, I’ll talk to some of them about it anyway.

Thursdays are presentation day at Hacker School, and quite a few people got up and gave short (strictly limited to two minute) presentations. I went last and gave my talk on noobs: how online communities welcome new users. It was apparently a rare format (not many people have talked about not-code during a presentation), but I actually plan on giving a non-technical talk each Thursday just to mix things up, if I can find enough topics. (Maybe a talk on why Terminal_ fell apart?)

Some people were leaving to go to a bar and play Cards Against Humanitybut that’s actually not a game I particularly enjoy (once the shock value has worn off, it’s just offensive Apples to Apples). I was going to see if anyone was interested in playing a game that I built, “Code and Cred”, but everyone seemed to be super in  to CaH, so I went back to work on Budgeted.

StarCraft 2’s World Championship Series is this weekend, and I watched a lot of that at the school before getting on the train and heading back. I figured that I would just be watching it in my hotel room, and Ian and Michael were at the school and I hung out with them for a while. The A took a long time to arrive, and there were a lot of maintenence crews on the line. They would stand inches from the train as we hurtled by them. I could feel the heat from the incandescent lamps that they hung on my face as we went by them.

Got back, browsed Reddit, mapped out the fact that I have to wake up in 3.5 hours, and wrote this blog post. Goodnight, and I’m off to WI tomorrow to start Graduation ceremonies!

From New York City,

–Erty

 

HS Day 6: Punderbowl

Probably a short post tonight because I got back to the room around midnight and just spent the last two and a half hours derping around on the internet.

Woke up this morning and went in to Hacker School. Ended up arriving pretty much right on time. I think leaving around 9:30 would be optimal, but tomorrow is my last day at this hotel so it’s kinda a moot point. I have to figure out how to get to Newark airport on Friday…

Worked on my Compsci assignment (Last problem set – ever!) until 1pm, then grabbed lunch with some other Hacker Schoolers (Jimmy, Joy, Nick, Martin, and some others) at a sandwich shop near the school. Ate at James J Walker Park, which is about two blocks from the School. Martin is from Sweden, and Jimmy and I talked with him for quite a while about Swedish politics and worldwide environmental issues.

Found some people on our internal chat app who were interested in starting a small D&D group for weekends. It would be nice to have something to do Sat/Sun. Otherwise I might end up going in to Hacker School 6 days a week out of boredom.

Returned to Hacker School and spent some time working on Budgeted. Got hungry around 5 and decided to do something different to distract me until 6:30. Joe had posted on our internal chat app that he wanted a Javascript/JQuery code review, so I went and found him at the other end of the space, and we sat for a while and went through his code. He had written a cool little JQuery flashcard app which used localstorage, and it was well programmed, with a few mistakes that weren’t particularly novice. We went back to my computer and I showed him around Budgeted for a bit. Nina joined us in a conversation about Hacker School and nerd culture.

I had coordinated with Nick and Alan earlier that day to go see Punderdome 3000, which is basically a pun-making competition. 16 contestants vie for audience cheers by performing 3 minutes of puns on 90 seconds off preparation time. It was very well done, and the father/daughter team that runs it was amazing. Beer was $7, though, but I guess that’s New York? I’m not going to go into super detail, since as far as I can tell they had a film crew there and it will probably show up on Youtube eventually.

The long line for Punderdome. We arrived 30 minutes early and still didn't get seats.

The long line for Punderdome. We arrived 30 minutes early and still didn’t get seats.

Terrible picture of the Punderdome stage.

Terrible picture of the Punderdome stage.

Returned to the Hotel on the A, and a guy got on and recited some of his own poetry. He was very confident and had a great speaking voice, but the other people on the train didn’t seem to react much. He called himself “Poet”. I thought it was a neat experience.

From New York City,

–Erty

 

HS Day 5: Finally Social

Woke up this morning a bit tired – I had caffeine yesterday, which makes me insanely productive but also totally unable to go to bed at night, so I stayed up until about 2am watching StarCraft. As you can probably tell by the timestamp for this post, I had caffeine today as well. Sigh.

Showered with my new shampoo, and all nice and clean I faced the day. Got to hacker school at about 10:32, which was almost perfect. Looks like I can leave the hotel as late as 9:40 and make it in on time. Met with my 6-person group and discussed what we all had spent our first day on. Joy had been working on some WebGL tutorials; Joy refactored a DOM selection library; Paige worked on learning C. I can’t remember what Alex and Carl were working on (and testing my memory was the whole point of writing this down). All very cool projects.

I skipped breakfast this morning, so I drank tea while working on some features for my grandpa’s airline database – the ability to group airports by city (e.g. all of the NYC airports). Turns out the flight data is actually already stored per city, so you couldn’t differentiate between the airports if you wanted to. A bit of wasted time but all in good measure. I put out a call for anyone interested in helping me pair program on Budgeted (working title) a javascript app for keeping track of organization finances with various budget lines.

Grabbed lunch at Getting Hungry, a pretty impressive sandwich/wrap bistro just a few blocks from Hacker School. I tried to go to Chipotle but the line wrapped around the entire store. Actually ended up being excellent – I had a turkey, avocado, and tomato sandwich that was delicious.

Walked back to Hacker School and ended up pairing with Richard for about an hour on learning React, which was awesome – I blazed through the tutorials, but he had a real attention to detail, and it forced me  to slow down and realize just how much nuance and complexity I was missing in my speed-reading furor. I ended up learning about learning as well as learning about React, which might prove to be more useful in the long run. React looks like it’s going to be pretty awesome, though.

I spent a moment fixing the internet here – everything was on Channel 1 and it was causing a lot of interference. I messaged the facilitators and one of them moved the backup router over to channel 6, which was pretty much empty:

Stacked Wifi at Hacker School - Oh No!

Stacked Wifi at Hacker School – Oh No!

Richard mentioned CSS pre-processors like SASS and LESS. I decided now was as good of a time as any to learn one of these, so I started writing in SASS. Turns out SASS uses a Ruby on Rails program to compile to CSS, which I didn’t really want to install. So instead, I wrote a terrible python program, which calls http://sass-lang.com/try.html, and uses their backend compiler to generate and scrape the CSS using a web call. Really though, I broke pretty much every coding convention, used outdated libraries, and even parsed HTML with Regex. Basically, it works, but in a really awful way. Gets my SASS compiled in the end and that’s what matters, I guess.

I committed it to Github anyway, if you want to check it out: https://github.com/ertyseidel/snac

Started in on the main app and worked on that until I got really hungry around 5:30. Stepped out and grabbed a Chipotle burrito – they’re up to $11.25 for a steak/guac, which is kind of ridiculous. I assume that’s because I’m in New York, though, and pretty much everything is expensive here.

Returned to Hacker School and found that someone has tickets to a Postal Service show next Friday that they can’t go to, so I pinged them and said I would take it! If all works out, that will be an awesome experience.

Walked with about a dozen other Hacker Schoolers to get Ice Cream and hang out in the park.  We stopped at Big Gay Ice Cream, which had a hilarious design:

Big Gay Ice Cream

Big Gay Ice Cream

Walked over to Washington  Square Park, and hung out on the grass for a while. I ended up talking with Jay from Iowa, and Nick (one of the Facilitators) about life in NY, graphic novel theory, and west/midwest distinctions. Turns out very few of the Hacker Schoolers, even in summer, are college students, so I’m probably one of the youngest here.

Washington Square Park

Washington Square Park

Hanging out with Hacker Schoolers

Hanging out with Hacker Schoolers

Walked with Allison (A facilitator) and another student whose name I can’t remember to West 4th station, and caught the C, which as Allison explained to me is like the A but actually stops everywhere. I asked her a lot of questions about living in NYC and how the subways work, and I think I have a better understanding now, which should help me out in getting around the city.

I was kinda planning on hanging out at Hacker School until late tonight instead of coming home (I’t’d be easier to work on my math homework without distraction at HS) but I knew I wouldn’t be able to get back in to the building. Once we have keycards we’ll all have 24-hour access, but that’ll be later this week or early next week.

Watched a lot of SC2 and got a math problem and a half done before realizing that it was 2am and I hadn’t written my blog post yet. Tomorrow I plan on finishing my math programming in the morning, which isn’t really in the spirit of Hacker School but it’s better to bend the rules than not graduate! Then more work on Budgeted, which I’m pretty excited about.

But for now, sleep.

From New York,

–Erty

 

Edit: I just want to mention, more for record-keeping than anything, that my left knee started bothering me yesterday, and especially today. I’ll be keeping an eye on it for a while – cursory googling says creaky joints (which I have) accompanied by pain is often a reason to see a doctor. Not freaking out yet but if it doesn’t go away in a few days I’ll do something about it.