Showing posts with label ruby. Show all posts
Showing posts with label ruby. Show all posts

Thursday, March 3, 2011

gem list error

I've been getting this error frequently during or after running a process which uses Ruby intensively. So far I have no solution other than restart. It also affects all other gem commands, including gem --version.

$ gem list
line 5: [path]: Argument list too long
line 5: [path]: Unknown error: 0

I'm still looking into how to fix this.

Friday, February 25, 2011

on the beach

I'm in Chicago, on the "beach" with some other TWUXXers getting our environments set up for next week, when we're on a small project spike... using Rails 3.0, JBehave, some other stuff...

On an unrelated note, I'm trying to get Bugzilla installed and configured. Conclusion: why are we using this anyway?

I went to a RoR101 session at lunch today... was interesting but the audience was very diverse in knowledge level.

The grocery store convenient to the Aon center is http://www.bockwinkels.com/

rvm set default ruby to system

rvm reset

Friday, December 17, 2010

Ruby 1.8 multithreading: fail

Ruby 1.8 "multithreading" is not real multithreading. It ends up that the entire VM blocks on any I/O. Well, hell.

Discovered (and probably soon solved) by rancorbeast.

Other guy's ideas: http://timetobleed.com/fixing-threads-in-ruby-18-a-2-10x-performance-boost/
(Just fixes the performance issue, not the fact that they don't provide useful concurrency.)

Saturday, December 4, 2010

Euler 13

Today I learned about Ruby inject, otherwise known as a left fold. http://en.wikipedia.org/wiki/Fold_(higher-order_function)

nums.inject &:'+'
&: takes the ... and calls to proc which is a callable object. with the provided arguments... the result is that you can take a method name on one of the array objects (like +) and ...do it.
1.send '+', 2

Assuming that you've assigned nums[] to hold the data you're dealing with, then puts nums.inject(0) {|a, b| a + b} will get you the answer 9and then you just take the first ten digits)

A much less elegant way to do this is
sum = 0
for i in 0..nums.size-1
sum = sum + nums[i]
end
puts sum

Once you understand what the notation does, it's an elegant way of doing it. But the uneducated will be extremely confused. There is all sorts of evil to it.

Wednesday, December 1, 2010

quantum crypto

Quantum crypto is what I claim to be interested in. It would help if I took some time and poked around in advanced math. I made it through Calculus 4 (didn't know that existed, did you? Me either) but I stopped there for reasons of practicality- i.e. gotta get the degree, get out, and pay pack the loans.

I don't love math enough to chase it in my free time, but at the same time I like it enough that I choose it over other occupations when it's one of a set of options... and frankly once you get past algebra, math and numbers are differentiated by many factors.

I guess I'll go donate to the EFF and go back to writing Ruby of slowly increasing quality.

Friday, November 12, 2010

Euler project 11..n

So, Euler problems 1-10 have increased my knowledge of ruby, python, and pain. It's been fun, and took longer than I wish it had. Obviously it's time to start on #11.

11. http://pastie.org/1306770 This could use some refactoring, but it works. It took me a bit to figure out, but I learned a lot, and didn't steal anyone's code. Although rancor did tell me that string.split existed.

16. http://pastie.org/1342335 This one was disturbingly easy and I don't know why. Maybe I'm getting better at Ruby. Or their ranking system is off. Something. Yes, I skipped 12-15 so I could do this one quickly and feel happy.

20. http://pastie.org/1342458 This one was very similar to 16. Doing one makes the other easy.

13. http://pastie.org/1348523 my brute-force solution.

14. http://pastie.org/1348526 my brute-force solution. http://pastebin.com/JVDVBL0b rancorbeast's elegantish solution.

Thursday, November 4, 2010

Euler Project

I'm doing problems from the Euler Project just now. My code is hideously embarrassing, but it's all my own and I'm kinda proud that I can write the stuff at all, considering that less than a month ago I might've looked at the problems and despaired, or at least made headway much more slowly.

My profile: http://projecteuler.net/profile/geeklinda.png I wish it said which specific problems I've solved...
  1. http://pastie.org/1273530 An alternate and very elegant solution from rancorbeast ((1..(1000 - 1)).reject { |i| i % 5 != 0 && i % 3 != 0 }).inject(0) {|a, b| a + b}
  2. http://pastie.org/1273527
  3. http://pastie.org/1273740
  4. http://pastie.org/1285750
  5. http://pastie.org/1290420 Code blatantly stolen from 17 Sep 2005 03:20 am post by Olath at http://projecteuler.net/index.php?section=forum&id=5 (can't access if you haven't already solved the problem) ... yes there is a discrepancy here. :)
  6. http://pastie.org/1285746
  7. http://pastie.org/1293957 (stolen from forums after getting answer)
  8. http://pastie.org/1285739
  9. http://pastie.org/1293953 (All mine. I'm proud of it. It runs pretty quickly. finding an answer took me several tries for some reason.)
    rancorbeast beat me by miles with the oneliner below.
    (1..500).each {|i| (i..500).each {|j| if i + j + Math.sqrt(i ** 2 + j ** 2) == 1000; print i * j * Math.sqrt(i ** 2 + j ** 2); end } }
  10. solved in python.
Euler 11..n will be in a new post.

Reddit:crypto makes my day

I finally discovered reddit:crypto (and also reddit:ruby) thanks to a guy I ran into at the RubyChicago event I blogged about a few days ago. Actually, he mentioned how much he liked reddit:python, and I went from there...

Anyway.

Tuesday, November 2, 2010

Amp talk @ ThoughtWorks

These are straight notes taken during the presentation and posted during the clapping. They may be updated later to add explanation and details. Presentation: 6:30pm-7pm, + questions.

Talk is by Justin Love
AMP: Mercurial.

His first version control was http://en.wikipedia.org/wiki/Microsoft_Visual_SourceSafe ...soon learned better. had to let Windows ppl in, so used Hg (git was no-windows in 2007)

Michael Edgar, Ari Brown. User seydar
Current version: Amp 0.5.3

Starting to implement git support. Which is hard. Started over and scrapped the old one. Learned a lot. This time: modular. Amp frontend. Git is written in C. Mercurial is written in Python. Monotone is in C==, SVN is in C?

There's not much from Ruby on here. http://en.wikipedia.org/wiki/Comparison_of_revision_control_software and part of the manifesto is to change that.

briefly mentioned

Amp will be somewhat like ActiveRecord? In that it translates...

Talking about the rebuilding of Rails 3 around modularization. Common api to things.

Showing off the ability to modify/rename commands. Also looking @ code.

This is using Trollop. What's Trollop? http://trollop.rubyforge.org/ "A commandline parser for Ruby that gets out of your way. "

Discuss billing command parsing... "estimate time spent" How many ppl here just understood those last few slides? (about implementing billing estimate using amp)?

in amp, a command will be defined as a class. Can use Ruby built-in modules to customize commands. (hwa?)

git output- not standardized. Many problems. Get around this by amp-grit instead of amp-git? http://grit.rubyforge.org/

I would like to see the version of the manifesto. Link?

There's a guy w a fancy camera taking pics. I want a camera like that. I wonder where the pics will be posted?

Questions:

Q svn will be supported?
yes. problem yet to be tackled. svn workflow is very different... haven't addressed problem yet.

Q what distinguishes amp? what makes you choose it over Hg? or a different system?
It's a general system. Well, it will be a general system. "Ignore the ppl who don't care right now."

"This is my RubyConf talk, I have to add 15min to it, so give me suggestions.

To present at one of these things, talk to chicagoruby.org via email.
Elephant and Castle now.

Saturday, October 30, 2010

Rspec and pair programming

Friday I:
- pairprogrammed for real for the first time. Ping-pong method == fun
- forgot my root password, (which I've used several times daily for the last month)
- remembered my password
- installed Rspec
- used Rspec
- was amazed at how useful Rspec is
- got quizzed on my (very small) knowledge of SQL and databases

I need to do a lot more writing tests before I can do it quickly and easily but my long-ago JUnit experience actually helped me catch on reasonably quickly... although I may have seemed like a dumbass a few times when I was trying to figure out what should be tested next.

Saturday morning I was one of the judges for the IIT Ethics Bowl contest. It was entertaining and slightly informative. Met a few cool people. I might help edit cases next year. IIT-local competition is much less... controversial and regulated than national competition. Which is not unexpected.

Monday, October 25, 2010

Heroku, rvm, and why the hell are they not working yet?

My friend dfr and some of his friends made http://stumie.heroku.com/ during http://railsrumble.com/ and he was showing me how cool it was and he sent me a project invite and I got an account and tried to install the heroku ruby gem so I could play too.

(Two other spare time projects from dfr: jshell.heroku.com and Ezy.)

By the way, this is based on what I read out of
$ history > heroku-history.txt | gedit heroku-history.txt

Make account on Heroku.
Have dfr invite you to the project. Check you email and click the link.
Check that Ruby and Git are installed.
$ sudo gem install heroku
$ heroku add: keys
$ heroku info --app stumie
$ git clone git@heroku.com:stumie.git
- get the rumble branch because master is outdated

Problems:
heroku: command not found
caused by how ruby installs on ubuntu if it's installed using apt-get
$ sudo apt-get install libssl-dev libreadline5-dev
$ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head
$ rvm

If rvm doesn't install (i.e. after installing you can't call it) try these
$ gem install rvm
$ rvm install 1.9.2

Did that work? if not, try:
$ rvm-install
$ run rvm

And/or go to the official howto
http://rvm.beginrescueend.com/rvm/install/

and/or irc channel here: http://webchat.freenode.net/?channels=rvm

home page for the rvm: http://rvm.beginrescueend.com/
after you get it installed, do rvm install 1.9.2
and then
$ rvm use 1.9.2

I have to remember to not push anything upstream yet!

Notes:
to see what gems you have,
$ gem list

Bandcamp

Bandcamp has an awesome application puzzle. (Which was featured on boingboing recently.) I solved it, with a few hints "try irb" and "how about using cat?" from rancorbeast, who didn't bother solving it since he's happily employed.

I'm not actually applying to work for them. I would really like to work for the company that's interviewing me (again) later this week. But puzzles are there to be solved. If my current endeavor falls through, maybe I'll give them another look.

I won't post the solution, since that's bad form. But let's just say that it was pretty easy, but still worth bragging about. If you're interested, this is the starting page: http://bandcamp.com/jobs

Thursday, October 14, 2010

CS GRE

I have a study prep book for the CS GRE. I think the book is a year or few out of date, but the problems in it are lots of fun- which is to say that some of them are goddamn complicated.

I'm still halfway through four CS books because life is all complicated and stuff. Hopefully I'll get to finish them soon. They rock.
List:
CS GRE (I'm not taking it, just reading the book)
Coders at Work (big book!)
Practice of Programming
Design Patterns

and I have a couple more sitting around for when I get done with those. Mostly Ruby stuff.

Wednesday, October 13, 2010

Yesterday was Ruby-themed

I spent most of yesterday solving a (fairly simple) problem using Ruby. Under a hundred lines of code (and refactoring could cut that down by half or more, I think!)

It was a great learning tool, though. I know a hell of a lot more about Ruby than I did two days ago. I want to do that all the time.

I'm going to need some more coffee if I'm going to do it this afternoon, though. Didn't sleep well. Need a nap. or a deadline. I like deadlines. Also coffee.

Zzzzzz.

Tuesday, October 5, 2010

ChicagoRuby Meetup at ThoughtWorks

Oct. 5, 2010
6-8pm

Presentation 1:
Jasmine for JavaScript testing: probably better than what you've been using.

Presentation 2:
New application: http://gathers.us/ for event management.

By the way, Obtiva is hiring. Ask the presenter about it at http://twitter.com/#!/ethangunderson

"The rails community really loves Mongo- they love basically everything that is new and shiny-"

His presentation includes the Picard facehand. Picture. I like this guy.

"It just works! It's all ponies and stuff. That's actually a really terrible idea, I think... ORMs are worthless if you don't understand what they're doing."

MongoMapper and Mongoid. (These do what they wanted to do but they didn't use them because of the above quote?)
"Mongo isn't single-server durable." has to do with write path. Must have at least two notes in a cluster for durability.

"Our adventure in data modeling: "
Option 1- separate events and groups. bad idea. option 2- embed events in groups. but this is a bad idea because there's a limited doc size. 4mb limit! "It's so people like us don't do thinkgs like that."
Practical limit is 100-500k, depending who you ask. Because tossing that repeatedly across the network is just irrational.
option 3- sngle collection inheritance. Worked well, but learned; if you migrate into it, the old events don't have a Type attribute, so you need to backfill that or everything will misclassify itself.

noSQL = "screw you, DBAs!" (but not so much...)

Register at chicagodb.com for an event hosted by Obtiva on oct 18th.

Mongo Chicago IIT Oct 20th.

Go to spkr8.com/t/4704 to review his presentation.

Tuesday, September 21, 2010

more books

I picked up everything that I passed that looked interesting.

1. Ruminations on C++ by Koenig and Moo.
I was wrong. Put it back. (also, copyright 1996)

2. Ruby Phrasebook by Clinton
Wins best of show. I'm considering stealing it. http://www.amazon.com/Ruby-Phrasebook-Jason-D-Clinton/dp/0672328976

3. Object Solutions by Booch
Good narrative style, but you could find as much content by reading blogs for a while. There are some fun sections, including a discussion on how easy it is to build the wrong thing if management is being stubborn. Very dated discussion of project management. (i.e. waterfall is assumed, rather than agile dev)

4. Mastering Perl by Foy (O'Reilly book)
Obviously, anything O'Reilly is more or less worth reading. http://www.amazon.com/Mastering-Perl-brian-d-foy/dp/0596527241
Verdict: I think I'm in love.
Advanced regex, untainting data, debugging perl, benchmarking, strictures, Pod (documentation), perltidy ftw, ...
Obviously I'm not a Perl Master. I should probably be reading an introductory text, if anything. But I'm impatient. :) Besides, I'm playing too hard with Ruby.

Lol, "talk to the bear" - the practice of explaining your code aloud to someone- coworker, bear, rubber ducky... usually leads to you saying "Oh, nevermind, I got it."

"Coding is where laziness meets impatience... oh, and competence."

5. Computer Forensics for Dummies by Volonino and Anzaldua
It's very basic. Chapter one will dispell your ignorant ideas (if you had any) about privacy. It has some fnu details. Ch. 2-6 are legalese. Ch. 7 is a transition to Ch. 8, which has some good stuff for people new to the realm. 9-11 are mirros of 8, but about email, docs, drives. Ch. 12 = cell phones. The rest of the book is mostly legalese.

Anyone who thinks that this books qualifies them for something is, indeed, a dummy. But it would be a good starter text for a scifi author trying to branch out into soft cyberpunk. And it might serve to intrigue teenagers (or careerchangers) into giving the profession a deeper look.

"World War Web: The Big One" should be a short story about crypto, legislation, and privacy.

6. Innocent Code by Huseby (Copyright 2004)
Not as dated as some, but the section on SQL injection is a a little old (I should blog about that, hmn), and the bit about sending email with a false address, while fun, is generally protected against nowadays.

p.193-195 is basically the summary of a class I took last year. Yay, packets.

7. Crypto by Levy.
This one, oddly, (none of the others have) has been checked out. Seven times. The most recent one was in 2003, though. So... meh. Makes you wonder why libraries even bother to have books, right?
It actually looks somewhat interesting- humanizing tales of the creation of DES and other crypto firsts.

8. Open Source 2.0 edited by DiBona, Cooper, and Stone.
Glossy and orange, this book actually looks "modern." It's an O'Reilly, although it's not in the traditional visual format.
It mentions Mozilla and Slashdot by name in the index. In one of the appendixes, it provides the text of a few of the most common open source licenses.
I wouldn't call it worth buying, but here it is if you want it. http://www.amazon.com/Open-Sources-2-0-Continuing-Evolution/dp/0596008023

Right. Enough of that.