<andkerosine>
A fairly fleshed-out one, but it didn't have all the parts, so some credit is yours.
<ankurgel>
yes, wide awake after doing this now! :)
<ankurgel>
andkerosine, I changed everything now as if I was already thinking about how to do that.
<ankurgel>
directly changed the portion which were becoming and PITA
<ankurgel>
and *boom*, in next attempt - Success
<ankurgel>
s/and/a
<andkerosine>
Good stuff.
<andkerosine>
Pita bread, I mean. : )
<ankurgel>
Ha :D
<andkerosine>
Planning on sticking with Ruby for a while?
<ankurgel>
yes, this time, I'll stick to it.
<andkerosine>
It's an amazing all-purpose tool.
<andkerosine>
How's your C++ repertoire?
<ankurgel>
C++ is fine enough, I guess.
<ankurgel>
I still have to get habitual with Standard Template Library.
<andkerosine>
Gross.
<andkerosine>
: )
<ankurgel>
But, rest of things are okay and works most of the time. :)
<andkerosine>
Mm-hmm.
<ankurgel>
andkerosine, Yesterday, you mentioned something about making IRC bot. It sounds interesting.
<ankurgel>
How do we do that?
<andkerosine>
I only ask because that's the beauty of programming. Once you have the fundamentals, picking up new languages is mostly just familiarizing yourself with its syntax.
<andkerosine>
I didn't mention an IRC bot.
<andkerosine>
But I do recall there being talk of such.
<seanstickle>
That's sort of like saying picking up Japanese is pretty easy, once I have Icelandic down pat.
<andkerosine>
Not at all.
<seanstickle>
It's true in a sort of reductionist way. :/
<ankurgel>
andkerosine, yes. completely agreed. php, java, c++ are almost same. and ruby belongs to same branch of OOPS, so conceptually same, syntatically different.
<andkerosine>
Programming "grammars" are much less expansive.
<ankurgel>
hmm
<seanstickle>
Try giving a C programmer a bunch of Prolog code to learn. It takes a bit longer.
<ankurgel>
^ ?
<andkerosine>
It was an overgeneralization, yes.
<ankurgel>
Which prolog code?
<erikh>
one might suggest though that after learning a few of them, you develop skills to pick them up quicker.
<erikh>
that said, paradigms can be hard to learn -- see the oodles of sql users out there
<ankurgel>
after dealing with few languages and understanding that the entire focus is programming itself and not the language, person apparently becomes language-agnostic
<andkerosine>
Ah... hm, gotta disagree.
qpingu has joined #ruby-lang
<andkerosine>
If you're used to being able to have side-effects (as is nearly always the case), a purely functional language will be Greek at first.
<seanstickle>
If anything, after learning a number of languages, I am more partisan to some languages.
<seanstickle>
Not more agnostic.
<ankurgel>
hmm
<andkerosine>
Agnostic in your ability to grasp, not necessarily prefer.
<erikh>
agnostic means 'doesn't know'
<ankurgel>
andkerosine, 100/100 in that problem. YAY
<andkerosine>
I was looking for how to break it.
<seanstickle>
erikh: yeah, but colloquially, meaning "doesn't care"
<erikh>
seanstickle: fair
<andkerosine>
Only hiccup I could see was duplicates in the groups.
<nofxx>
"We cannot know with certainty if God or Christ exists. They COULD. Then again There COULD be a giant reptilian bird in charge of everything. Can we be CERTAIN there isn't? NO, so it's pointless to talk about."
<jorgenpt>
heftig: Neat
<ankurgel>
heftig, eww! fantastic
<jorgenpt>
Enumerable has so much cool stuff I forget about
<andkerosine>
Best thing in programming.
<ankurgel>
I can use group_by to group from array/range specified on left according to condition specified at right?
<seanstickle>
To crush your computers, see them driven before you, and hear the lamentations of their fans?
<andkerosine>
Specified in the block, "at right" is a bit incorrect.
<heftig>
ankurgel: it will sort the elements into a hash, with the return value of the block as key
<andkerosine>
ankurgel: irb will forever be your friend.
<ankurgel>
andkerosine, yes, tried it already after he posted :)
<andkerosine>
Noice.
<ankurgel>
and grouping some other patterns now.
<andkerosine>
ankurgel: Linux user?
<ankurgel>
andkerosine, thorough. :)
<andkerosine>
You, sir, are good people.
<andkerosine>
How many dollar words in /usr/share/dict/words? : )
<ankurgel>
er. you want to program it?
<ankurgel>
that's dictionary file, right?
<andkerosine>
Eh, not urgent.
<ankurgel>
oh
<ankurgel>
look dollar
<ankurgel>
done
<andkerosine>
Haha.
<andkerosine>
A "dollar word" is a word whose alphabetical value is 100.
<andkerosine>
Where a = 1, b = 2... z = 26.
<seanstickle>
Ah, gematria
wmoxam has joined #ruby-lang
<andkerosine>
seanstickle: Bless your beautiful soul.
<andkerosine>
I have been looking for that word for years.
<andkerosine>
Just a thought. It's a nice practice program, methinks.
<seanstickle>
Old school number/word mysticism
<ankurgel>
we can code it in rb, to check for dollar word easily.
<ankurgel>
but iterating over every word, will be slowwwww
<andkerosine>
Not at all.
mistym has joined #ruby-lang
<ankurgel>
hm
burns180 has joined #ruby-lang
<ankurgel>
andkerosine, this is that file -rw-r--r-- 1 root root 910K 2009-04-29 23:22 american-english in /usr/share/dict/
<ankurgel>
910K. hm
<ankurgel>
98569 words in my dict
<andkerosine>
Heh, 234937 in mine.
<jorgenpt>
I found a horrible oneliner to do it
<andkerosine>
Me, too.
<jorgenpt>
2296 dollar words in my dict, out of ~235k
<andkerosine>
Are you redeclaring the alphabet inside of the #find block?
<andkerosine>
Or lots of #ord-ing?
<jorgenpt>
Lots of #ord-ing
<ankurgel>
heftig, instead of using .value to extract values from hash. What if I wanted other part of hash?
<nofxx>
ankurgel, especially for you, that are playing and learning ruby, pry is incredible tool http://pry.github.com/
<ankurgel>
which method for that?
<andkerosine>
ankurgel: #keys
<jorgenpt>
andkerosine: .keys
<jorgenpt>
Err. Tab completion fail. :-p
<andkerosine>
Haha.
<nofxx>
who is* .. pardon my français
<ankurgel>
okay. :) I tried #key first out of random and it failed.
<andkerosine>
#keys.first? : )
<ankurgel>
yes, my bad jorgenpt
<ankurgel>
no.
<ankurgel>
.key
gjaldon has joined #ruby-lang
<jorgenpt>
andkerosine: Mine's 136 characters, including generous application of whitespace. How about you?
<hagabaka>
if you're trying to find a key that corresponds to a known value, there's no built-in method, but there's Hash#invert, or you can find it manually
<seanstickle>
Wait, what game are we playing?
<seanstickle>
Calculating dollar words?
<jorgenpt>
Yup
<jorgenpt>
Oh, hey, Kernel#open, where have you been my whole life?
wmoxam has joined #ruby-lang
<seanstickle>
113 chars here
<jorgenpt>
107 after killing whitespace and using shorter aliases
<seanstickle>
Are we assuming only lower case words?
<jorgenpt>
I'm not
<seanstickle>
Or do capital letters have different values?
<seanstickle>
a=A=1?
<jorgenpt>
Yes
<jorgenpt>
That's my assumption.
<andkerosine>
Mm-hmm.
<andkerosine>
Sorry, going for sub-100. : )
<seanstickle>
107 when I kill whitespace
<seanstickle>
Does this include the name of the file to read?
<seanstickle>
Because mine does
<jorgenpt>
Yep
<seanstickle>
What's the name of the file
<seanstickle>
So I am not using a longer named file than you
<jorgenpt>
This is code that I can put "puts " before and ".count" after, and have it return something
<andkerosine>
/usr/share/dict/words
<seanstickle>
Ok, same with me
<jorgenpt>
Ditto
<andkerosine>
jorgenpt: I'm using #p and #size.
<seanstickle>
andkerosine: you have less than 100?
<andkerosine>
Gonna get there.
<andkerosine>
I can almost taste it.
<jorgenpt>
I'm measuring with "echo -n ... | wc -c"
<jorgenpt>
I'm at 105
<andkerosine>
I think I /might/ be doing something kind of clever. We'll see.
<andkerosine>
113 at the moment. : /
<ankurgel>
andkerosine, how do I convert a character into it's equivalent ascii value?
<seanstickle>
That's telling
<ankurgel>
for a string or a char, I can use: "ankurgel".each_byte{|c| puts c}
<ankurgel>
but, that's tiresome
<andkerosine>
ankurgel: 'A'.ord == 97
<andkerosine>
97.chr == 'A', naturally.
<ankurgel>
cool!!
<ankurgel>
ord denotes?
<jorgenpt>
I'm at 100!
<andkerosine>
ankurgel: Erm... it's always just been what's used, heh.
<jorgenpt>
ankurgel: Ordinal, I think?
<andkerosine>
Almost every language uses chr and ord.
<ankurgel>
okay :)
<andkerosine>
jorgenpt: Don't show yet.
<andkerosine>
Or, go ahead... just don't post here.
<andkerosine>
I'll be tempted to look and inevitably will.
<jorgenpt>
Hehe :-)
<seanstickle>
100!
jxie has joined #ruby-lang
<hagabaka>
have you decided on what is the input and output of your code?
<jorgenpt>
I've been assuming the list of words that are dollar words
<hagabaka>
do you have to hardcode the path and read the file yourself, and do you return the count or print it?
<jorgenpt>
(from a newline separated dict file)
<jorgenpt>
And former, with /usr/share/dict/words as the path
<andkerosine>
hagabaka: Final result should be an outputted number.
<jorgenpt>
andkerosine: You're on OS X, right?
<jorgenpt>
andkerosine: Oh, the number of words and not the array of words?
<hagabaka>
yeah I'm just saying to have a meaningful contest there should be defined rules about these
<jorgenpt>
Hehe, yes.
<jorgenpt>
seanstickle: 99 *pffft*
<jorgenpt>
(with return value being list of words that fit the bill)
<ankurgel>
bleh. Have some fest to attend somewhere. Off I go.
* ankurgel
will return in evening with more tomfoolery. RUBY #FTW
<ankurgel>
andkerosine, see you. thanks again. :)
<seanstickle>
Dnag
<andkerosine>
jorgenpt: No, Debian. But yeah, the number of words.
<jorgenpt>
Oh herp derp, 96.
<andkerosine>
Damn...
<jorgenpt>
That's the array.
<jorgenpt>
Let me rebuild it to return the count without something as dumb as .count
<seanstickle>
Wait, are we returning the list of words?
<seanstickle>
Or just the total count of the number of words
<jorgenpt>
Oh, you're saying we're including p(x.size) in the count?
wmoxam has joined #ruby-lang
<jorgenpt>
seanstickle: My impl is the former
Slackwise has joined #ruby-lang
<seanstickle>
I'm just returning an array of all the dollar words
<andkerosine>
I mean, it doesn't change up our solutions, I imagine.
<andkerosine>
Just whether or not we're calling #size at the end, no?
<seanstickle>
Well, it changes the length of mine
<seanstickle>
Which I gathered was the point
<jorgenpt>
Yeah
brushbox has joined #ruby-lang
<jorgenpt>
And you can take completely different approaches for it
gregf has joined #ruby-lang
<seanstickle>
Ok, time to share implementations
<seanstickle>
Cards on the table gentlemen
burns180_ has joined #ruby-lang
<andkerosine>
Just a tick.
<andkerosine>
Final solution should output a number, or an array of dollar words?
<jorgenpt>
I'm a puny 109 with the whole "print the count"
<andkerosine>
I thought #scan(/.+/) an #bytes were pretty clever.
<seanstickle>
andkerosine: Yours does not address capital letters
<andkerosine>
Feck.
<jorgenpt>
101: p open("/usr/share/dict/words").each.select{|n|n.downcase.chars.inject(-14){|m,c|m+c.ord-96}==0}.size
<jorgenpt>
Just something I started but didn't optimize @ 109: open("/usr/share/dict/words").each.inject(0){|m,n|m+(n.downcase.chars.inject(-14){|m,c|m+c.ord-96}==0?1:0)}
<jorgenpt>
(look ma, no #size!)
<andkerosine>
99: p File.read('/usr/share/dict/words').scan(/.+/).select{|w|w.upcase.bytes.reduce(:+)-w.size*64==100}
<andkerosine>
Not sure why you'd opt for downcase instead of upcase, gents.
<jorgenpt>
Huh, I guess map+reduce is less than inject.
<jorgenpt>
Hah, yeah, that was a silly assumption :-p
<seanstickle>
jorgenpt: you don't need the each in your first one
<seanstickle>
jorgenpt: saves some space
rushed has joined #ruby-lang
<jorgenpt>
Oh neat
<andkerosine>
jorgenpt rather clearly wins. He's at 101 with all sorts of potential optimizations.
<jorgenpt>
That I never realized, which is just embarassing
<seanstickle>
I am missing that inject(-14) thing
<seanstickle>
Not sure what it's doing
<andkerosine>
Cancels out \n?
<seanstickle>
Ah
<jorgenpt>
Cancels out \n
<andkerosine>
Does it cancels out \n?
<jorgenpt>
And moves the 100 to the LHS of the expr
<fragmachine>
how would I match this '\360' with regexp when I don't know what the numbers will be? I tried grep(/\/[0-9]/) but it doesn't work. I only want to return something if the slash is present as well as the numbers
<andkerosine>
=~ %r{\\d+$}
jkyle has joined #ruby-lang
<andkerosine>
Not quite...
<andkerosine>
'\360' =~ %r{\\\d+$}
<andkerosine>
Breaks if the string is double-quoted, though.
<andkerosine>
And the $ is maybe unnecessary...
s0ber has joined #ruby-lang
<banister>
andrewvos: sup
<fragmachine>
I get this error '(irb):17: warning: regexp has `}' without escape' and it doesn't return anything
<fragmachine>
I'm on 1.8.7
<andkerosine>
Well, then, gimme a sec. : )
<fragmachine>
awesome thanks :)
<andkerosine>
You're mistyping something.
<andkerosine>
1.8.7 :002 > '\360' =~ %r{\\\d+$}
<andkerosine>
=> 0
<andkerosine>
banister: Context tells me that was meant for me, but I don't want to presume.
<banister>
andkerosine: hehe, actually it was for andrewvos, i was going to answer his tweet on irc :)
<andkerosine>
Ah, all right.
<fragmachine>
I'm trying to put it in grep - a.grep(/=~ %r{\\\d+$}/)
<andkerosine>
Ah, haha.
<andkerosine>
%r{} is synonymous with //
<andkerosine>
I just resort to it out of habit whenever slashes come into the picture.
burns180 has joined #ruby-lang
<andkerosine>
I think if you use //, you'll have to escape your \ with \\\\\\\\, believe it or not.
<andkerosine>
So I strongly recommend %r{}.
<fragmachine>
so many?
<andkerosine>
Strange, huh?
<fragmachine>
I'll say
<fragmachine>
can you use %r{} with grep?
<andkerosine>
Certainly.
<andkerosine>
foo.grep %r{...}
<andkerosine>
//.class == %r{}.class
<fragmachine>
awesome that works perfectly
<andkerosine>
Sorry, disregard that bit...
<fragmachine>
what does %r and {} do?
<andkerosine>
Can't remember the specifics, but I know I remember reading a horror story about eight slashes somewhere.
<andkerosine>
Ruby took those "contextual strings" I call them from Perl.
<andkerosine>
You know how escaping quotes is annoying?
<andkerosine>
%{} is used to wrap the string in "agnostic" quotes, so that you don't have to bother escaping any.
<andkerosine>
%q{} wraps it in single quotes, and still no need to escape.
<andkerosine>
Same for %Q{}, except double quotes.
<andkerosine>
Then there's %w{} which takes the insides and splits on spaces, so that you don't have to ['do', 'this', 'annoying', 'thing'], you can just %w{put words in here}.
<fragmachine>
man that's all awesome
<fragmachine>
Ruby rocks
<andkerosine>
And then %r{} lets you pass in a Regexp without having to escape forward slashes and the like.
<andkerosine>
Sorry for the invasion.
<andkerosine>
But yes, Ruby is absolutely amazing.
<andkerosine>
Matz is a beautiful human.
<fragmachine>
I've been learning C for some class and it's like smashing your head against a wall repeatedly for hours
<andkerosine>
Man, after being in Ruby all day and then having to look at C... nightmare.
<fragmachine>
especially after playing around with ruby first
<andkerosine>
Mm-hmm.
<fragmachine>
things just work in Ruby
<andkerosine>
Pretty much everything about Ruby feels incredibly "natural", which is such a strange thing to say about a programming language, I think.
<fragmachine>
its true though
<andkerosine>
I mean, the language was designed from the very start to be that way, so it makes sense enough.
Natch| has joined #ruby-lang
<mistym>
I wish C didn't have the combination of verbose syntax and linguistic complexity. I understand that with a lower-level language a lot of stuff is going to be necessarily harder, and that's fine, but the syntax could stand to be a lot more readable and less intrusive.
<andkerosine>
mistym: Particular examples?
srbaker has joined #ruby-lang
A124 has quit [#ruby-lang]
maek has joined #ruby-lang
<andkerosine>
Just how explicit you have to be, in general?
A124 has joined #ruby-lang
<fragmachine>
painfully explicit
<mistym>
Yeah, exactly.
<mistym>
Mandatory parens, curly braces up the wazoo, etc.
<andkerosine>
Ruby has done terrible/wonderful things to me.
<fragmachine>
haha
<andkerosine>
Typing parens, braces, and semicolons has been second-nature for so long.
<andkerosine>
Now I type them and feel dirty.
<mistym>
I mean, it's not lisp, but it could stand to be a lot pleasanter to write and quicker to visually parse.
<andkerosine>
Lisp is nice on the parsing eyes, I think, just not the aesthetic ones.
<andkerosine>
Purely functional means tiny little pieces.
<mistym>
Yes, I suppose it's an acquired taste. To the untrained eye it's hard to parse, but I'm sure that goes away with familiarity.
<andkerosine>
It's mostly just a byproduct of proper indentation.
<andkerosine>
Could be the Python speaking...
<mistym>
I haven't done much Python, but after a little poking around in Coffeescript I'm really appreciating the indentation.
<erikh>
heh, I was just getting through lesson 30 of lpthw
<erikh>
it's a neat language
slaytanic has joined #ruby-lang
TinhTienMau has joined #ruby-lang
rippa has joined #ruby-lang
TinhTienMau has joined #ruby-lang
seanstickle has joined #ruby-lang
burns180_ has joined #ruby-lang
<banister>
erikh: why do u like it, human child?
TinhTienMau has joined #ruby-lang
x0F__ has joined #ruby-lang
TinhTienMau has quit [#ruby-lang]
TinhTienMau has joined #ruby-lang
TinhTienMau has joined #ruby-lang
TinhTienMau has quit [#ruby-lang]
<banister>
mistym: i think C is pretty readable, except perhaps when people start doing weird pointer arithmetic or strange pointer declarations
TinhTienMau has joined #ruby-lang
<seanstickle>
Is there anything like Perl::Critic for Ruby?
<seanstickle>
I have searched, but I have not found.
<banister>
seanstickle: what is Perl::Critic sean
<heftig>
while ( *(i++) = *(j++) );
<seanstickle>
banister: thing that does static analysis of code to enforce a user-defined coding convention
<banister>
seanstickle: cool idea
<seanstickle>
Indeed
TinhTienMau has quit [#ruby-lang]
<seanstickle>
And I should find a Ruby version very handy indeed
<banister>
seanstickle: do you think it would make a floor feel good?
<seanstickle>
Not as good as a carpet would.
macmartine has joined #ruby-lang
<nofxx>
someday I'll make coffee for C, really simple actually.. just remove ';' and add 'do end'
manojhans has joined #ruby-lang
burns180 has joined #ruby-lang
srbaker has joined #ruby-lang
gnufied has joined #ruby-lang
dubellz has joined #ruby-lang
donaldwauchop has joined #ruby-lang
donaldwauchop has joined #ruby-lang
burns180_ has joined #ruby-lang
bgupta has joined #ruby-lang
<bgupta>
Hi I am working on am working on the second version of a ruby CLI utility I wrote. The first version had limited functionality and I was able to get away with OptParse. For the next iteration I want to be able to use subcommands. eg. mycommand commandheirarchyone finalcommand
<bgupta>
I also want to be able to support both global options as well as subcommand options.
<bgupta>
I want "free" help generated.
<bgupta>
I found Thor but it doesn't seem to support global options.
<bgupta>
An example of global options would be mycommand --debug commandheirarchyone finalcommand
<bgupta>
(I was able to get the subcommand thing working using Thor namespaces though..)
<bgupta>
can't fingure out how to get global options working.
<andkerosine>
"commandhierarchyone" is kind of obtuse.
<andkerosine>
I mean, I've only ever used OptParse, so I likely won't be able to help, but I could assist in the search if I better understood what you meant.
nofxx has joined #ruby-lang
nofxx has joined #ruby-lang
Heimidal has joined #ruby-lang
<andkerosine>
nofxx: What purpose is served in changing host like that?
<andkerosine>
I see it all the time, of course, but I've never seen the point.
<nofxx>
andkerosine, sorry mate, dunno what you mean
<nofxx>
irc host?
<andkerosine>
Mm-hmm.
<andkerosine>
You switch to unaffiliated, but is that for anonymity, or...?
<bgupta>
basically I want to be able to add "hammer --debug hosts list" (--debug would be a global flag/option that sets something globally.
<andkerosine>
Ah, gotcha.
<andkerosine>
Thor seems pretty... thorough, so I imagine it's got to be an option.
<andkerosine>
Is it that you're opposed to introducing string manipulation unless absolutely necessary?
<bgupta>
One would think... but it's not in the wiki, and I am not a good enough coder to figure it out by digging through the code.
<erikh>
banister: it's fast and the standard library is pretty solid
<erikh>
other than that? meh.
<bgupta>
string manipulation? I guess what I want is the CLI framework to handle the git style subcommand stuff for me, so I can focus on actually writing the code.
<andkerosine>
Mm-hmm.
<bgupta>
git supports global flags as well as subcommand specific flags and args, so I assumed that was a standard pattern..
<andkerosine>
Again, I'm sure it is, but I'm entirely unfamiliar.
<bgupta>
(I mention git, because many peopel mention Thor as a tool designed to write git style commands)
<andkerosine>
--global and -local, yes?
<erikh>
there's also extlib
<erikh>
which is what chef uses.
<andkerosine>
^ Far wiser Rubyist than I, and I require sleep.
burns180 has joined #ruby-lang
<bgupta>
erikh: Chef knife supports global flags? I didn't seem to when I last peeked?
<bgupta>
will check it out though
<erikh>
I may have missed the core of your question, but git doesn't support global flags either
<erikh>
at least, not afaik
<banister>
erikh: hey a guy was using p-dogg in production the other day, very interesting
<bgupta>
type "git"
<erikh>
banister: p-dogg?
<bgupta>
one example is git -c name=value <command> [<args>]
<erikh>
ah
<erikh>
trollop!
<erikh>
I forgot.
<erikh>
there's also slop, which I think can do what you want too.
<erikh>
I know for a fact trollop can.
<bgupta>
ok so I heard like a dozen different cli frameworks, gli, commander, boson, Thor, etc.. figured I'd start my way at the most popular.... and see.. will checkout trollop.
<hagabaka>
yeah, I hate that so many libraries have you subclass things to do things
<erikh>
dunno. subclassing feels pretty natural to me
<bgupta>
I am working on a massive cli utility that will have lots of nested subcommands, so I am kinda hoping my cli framework really really helps me with the basic stuff.
<erikh>
the cult of include seems like more pointless idealism
<erikh>
LOTS of things. 1.9.3 is a huge improvement even over 1.9.2
abcsdgad has joined #ruby-lang
<A124>
Oh. Thanks a lot. I meant by percentage general or something.. But This is still good. What is faster on rubygems please?
<injekt>
you'll have to search for specifics if you want benchmarks
<erikh>
yeah, there's no real thing as a general benchmark
<injekt>
or better yet, try some out yourself. As erikh says, there's a TON
<erikh>
and I'll direct you to the rubygems changelog for information on performance improvements.
<A124>
Yeah I should. But what he said gives me even more valuable information for me
<bgupta>
erikh: You know puppet?
<erikh>
injekt: I need something to do
<A124>
Nope.
<injekt>
erikh: more blawgh?
<erikh>
bgupta: a long time ago I worked on the test suite for it -- I use chef these days
<erikh>
injekt: give me a topic
<injekt>
hmm
<erikh>
something light on opinion and hard on detail & instrumentation -- I hate the DHH style blogs.
<injekt>
erikh: did you do Parallel computing lately?
<injekt>
ah, light on opinion
<erikh>
I did, but I don't feel comfortable talking about it with any authority yet.
Para has joined #ruby-lang
<bgupta>
erikh: cool.. I am basically writing "knife" for the foreman+puppet combination.. (Foreman kinda fills the same role as the node classification compnent of the chef server)
<injekt>
that's fair
<erikh>
bgupta: yeah, I keep hearing about it but i don't know much about it.
yxhuvud has joined #ruby-lang
<bgupta>
(I picked the name hammer as a play on knife.)
<erikh>
heh.
<erikh>
foreman is heroku's deal, right?
Zolrath has joined #ruby-lang
<erikh>
I'm *really* looking forward to the chef-server rewrite in erlang.
<bgupta>
No it's this guy Ohad Levy, who know works for RedHat.
<injekt>
yeah
<injekt>
what?
<erikh>
the ruby/java mess that is chef-server now is a bit of a cluster-f
<injekt>
David Dollar built the foreman I know
<injekt>
for heroku
<injekt>
maybe there's 2 foremans?
<erikh>
we could be talking about two different things.
<injekt>
aye
<bgupta>
Foreman is great in that it does full bare metal provisioning.
<bgupta>
ohh wait there is two foremans
<erikh>
foreman is a process manager, yes?
<erikh>
the DD foreman.
<bgupta>
the newer one, which I am NOT talking about, is much more popular in the ruby community
<injekt>
ah
<erikh>
I've been meaning to read it because that's what I'm working on
<erikh>
injekt: ?
<injekt>
erikh: was responding to 'which I am NOT talking about'
<erikh>
yes -- but is the foreman I'm thinking of (heroku's foreman) a process manager?
<injekt>
oh
<injekt>
yessir
<injekt>
managing the procfile stuff
<erikh>
raggi told me about it, but I haven't looked at it yet.
<bgupta>
erikh... there is a feature request to add chef support to foreman, and Ohad is open to it.. but noone working on the project uses Chef, so we don't have anyone that is really in a place to work on it.
<bgupta>
(hint hint)
<injekt>
it's pretty neat
<erikh>
heh
<erikh>
well, I don't have much bandwidth these days for big projects
<injekt>
amen to that :(
<bgupta>
If you ever want it, you can ping him on #theforeman (ohadlevy)
<erikh>
I have something big I'm working on already, and it's getting to the point where I'm running into the nitty gritty.... the last mile that's very draining on the brain.
<erikh>
bgupta: thanks, but I'll probably have to pass.
<injekt>
I wish I had more time for OSS lately
<bgupta>
ohad is open to ripping out facter and replacing it with a modular inventory service that you could plug ohai into
<erikh>
oh neat
<bgupta>
OSS is HARD.
<erikh>
there's a couple of ohai-alikes out there.
<erikh>
I also wrote this which might be able to assist
<bgupta>
yeah.. slat has theirs (grains) and cfengine has something too
<erikh>
it's not a comprehensive solution by any means, but it is a starting point if you just want to use the code
<erikh>
better than the ifconfig-scraping mess that facter and ohai use.
A1241 has joined #ruby-lang
<bgupta>
bookmarked, for anyone who picks up the project.
<erikh>
bgupta: doug maceachern has his own thing too, but I forget what it's called
<erikh>
it's basically ohai done in C
<erikh>
(which IMO is the right way to do it)
<bgupta>
My biggest problem is that I don't really know how to code, and just learned some ruby as I desperatly needed a CLI to interact with foreman
<erikh>
eh, looking at your code I'd say you're well on the way to being good at it
<erikh>
just gotta keep coding.
<bgupta>
(I knew bash/awk stuff)
<A1241>
erikh: Thanks for the info :) Sorry, I got VDSL2 disconnect xD .. Router was reconfiguring.
<erikh>
A1241: no problem.
<A1241>
No it was not, the shut it off
<bgupta>
It took me an very very long time to write the code you saw, but thank you.
<A1241>
Classic "dumb" familly bussines, instead of telling me, they plugit out
gjaldon has joined #ruby-lang
<bgupta>
(I spent a long time making sure it wasn't "embarassing", once I got it functional)
davidw has joined #ruby-lang
dous has joined #ruby-lang
rippa has joined #ruby-lang
rippa has joined #ruby-lang
burns180 has joined #ruby-lang
<erikh>
heh. my messaging system uses around 110 file descriptors to send 500k messages
<erikh>
I should probably fix that.
<erikh>
sorry, about 1.5 million messages
<erikh>
ruby test.rb > /dev/null 11.56s user 12.68s system 118% cpu 20.521 total
<erikh>
not bad really. 0mq is pretty badass
toretore has joined #ruby-lang
burns180_ has joined #ruby-lang
tbuehlmann has joined #ruby-lang
<bgupta>
It's frustrating as many of the sugary cli frameworks are missing different pieces, but working to fill the gaps, just none of them are quite there yet. e.g. - gli won't have support for more than one layer of command until v2. And boson can't support running it other than "boson commandname" (can't just run "commmandname". Thor doesn't seem to support global flags. I either have to wait, or do more coding than I ha
<bgupta>
hoped to do.
<bgupta>
Well more hand rolled "scafolding" than I had hoped to do.
<bgupta>
gli and thor both are very easy to use.
brianpWins has joined #ruby-lang
burns180 has joined #ruby-lang
greap has joined #ruby-lang
manojhans has joined #ruby-lang
burns180_ has joined #ruby-lang
Nss has joined #ruby-lang
burns180 has joined #ruby-lang
<erikh>
hrm. question: I'm dealing with a lot of file descriptors that get allocated very quickly. to route around some "too many open files" problems, I've inserted GC.start after my close calls.
<Asher>
if you use a block for opening files doesn't ruby close them?
<erikh>
what I'm wondering is if it makes more sense to queue and batch those closes for performance or not
<erikh>
Asher: sockets.
<erikh>
0mq sockets to be precise.
<Asher>
GC.start is going to traverse the heap at least once every time it's called
<Asher>
… not sure if that is responsive
<yxhuvud>
erikh: you could also increase the allowed amount of file descriptors. Not a solution that scales though ..
<erikh>
yeah, but doesn't 1.9.3 do it without stopping the world?
<erikh>
yxhuvud: yeah, the use case here doesn't make sense to apply ulimit
<Asher>
now that you mention it that sounds right but i'm not sure… i know it is cow now and i think that went with it being in its own thread.. but not sure what the status of that is now
A124 has joined #ruby-lang
<erikh>
yar. I'll ask a co-worker who's a lot more familiar with this specific class of problems.
ben has quit [#ruby-lang]
takaokouji has joined #ruby-lang
burns180_ has joined #ruby-lang
srbartlett has joined #ruby-lang
gnufied has joined #ruby-lang
robbyoconnor has joined #ruby-lang
SiliconDon has joined #ruby-lang
stamina has joined #ruby-lang
aza_kibou has joined #ruby-lang
machine1 has joined #ruby-lang
fragmach_ has joined #ruby-lang
<fragmach_>
anyone know how I could use a regexp to detect a sequence like this ""\006\221\263B\262\210H\256\221\3140m\246\256\210""? The numbers will change but I can split it into pieces or otherwise hack it up.
havenn has joined #ruby-lang
<bnagy>
awt?
<bnagy>
then how will the new sequence be 'like' that one?
<bnagy>
apart from having bytes in it?
<fragmach_>
I just need to know whether a similar sequence to that is returned. Its from a Cipher class, and if the password is wrong it returns a whole bunch of that gibberish
<bnagy>
that's not gibberish
<bnagy>
it's just non-ascii
<fragmach_>
oh ok, how can I work it into a more sensible state
<fragmach_>
?
<fragmach_>
or more useable
francisfish has joined #ruby-lang
<bnagy>
useable for what? I'm not trying to be difficult, but.. it's just a string of bytes
<bnagy>
it is not useful or useless inherently
<bnagy>
you could try to force_encoding 'UTF-8'
<bnagy>
if that fails then you're probably not looking at 'text'
<fragmach_>
Basically a method either returns "This is a message" or something similar, or it returns a sequence like that
<fragmach_>
I want to be able to say "invalid password" if I get a bunch of bytes like that
<bnagy>
that's the thing about symmetric ciphers, they always return _something_
<fragmach_>
yea it's annoying, I can;t just search for digits or special characters becuase they might be part of the message
<bnagy>
but unless you know for a fact that the plaintext is ascii or similarly constrained you can't tell if you have the right key
<fragmach_>
I tried making a regexp but it was to frusterating and I gave up
srbartlett has joined #ruby-lang
<fragmach_>
when I put the right key in I get a plaintext response
<bnagy>
ok then try the force_encoding trick
<fragmach_>
Ok I'll look into it
burns180 has joined #ruby-lang
tekin has joined #ruby-lang
<fragmach_>
I get undefined method `force_encoding'
<fragmach_>
do I need to require something?
<bnagy>
actually probably encode, sorry, that's what I do
fayimora_ has joined #ruby-lang
<bnagy>
except now I am confused cause it is not raising an exception like it should
<fragmach_>
I don;t have an encode method available, I'm on 1.8.7 btw
<bnagy>
on String?
d3vic3 has joined #ruby-lang
<bnagy>
ah 1.8.7
<fragmach_>
yea becuase macs come with that default
<fragmach_>
I have 1.9.3 but anyone I send it too wont
<bnagy>
I haven't used 1.8.7 for years. Does it have each_byte?
twittard has joined #ruby-lang
<fragmach_>
yea it has each_byte
<bnagy>
some_str.each_byte.all? {|b| b&128==0} # good string
<bnagy>
that is hideously non-portable etc etc
<fragmach_>
it says false
<bnagy>
for the bad string, it should
<fragmach_>
woot that's awesome!
<fragmach_>
yea returns true for good string
<fragmach_>
thanks heaps, I've been pulling my hair out for hours!
<bnagy>
it's a terrible way to do it
<fragmach_>
how does it work?
<bnagy>
but it will work for us-ascii
<bnagy>
well ascii is all 7 bit, due to legacy reasons
<bnagy>
so anything that has the top bit set (which is what binary & with 128 checks) is not ascii
<fragmach_>
ok well the message will always be set by my ruby program
<fragmach_>
so should be ok
<fragmach_>
I think
<fragmach_>
haha
machine1 has joined #ruby-lang
jbvp has joined #ruby-lang
looopy has joined #ruby-lang
<jbvp>
hi
<A124>
*chrrr*
apeiros_ has joined #ruby-lang
SiliconDon has joined #ruby-lang
burns180_ has joined #ruby-lang
benanne has joined #ruby-lang
kek1 has joined #ruby-lang
cyri_ has joined #ruby-lang
gnufied has joined #ruby-lang
burns180 has joined #ruby-lang
wmoxam_ has joined #ruby-lang
wmoxam has joined #ruby-lang
rushed_ has joined #ruby-lang
rushed_ has quit [#ruby-lang]
SiliconDon has joined #ruby-lang
burns180_ has joined #ruby-lang
francisfish has joined #ruby-lang
havenn has joined #ruby-lang
dejongge has joined #ruby-lang
sandbags has joined #ruby-lang
publicvoid_ has joined #ruby-lang
canton7 has joined #ruby-lang
Fullmoon has joined #ruby-lang
burns180 has joined #ruby-lang
tekin has joined #ruby-lang
thone has joined #ruby-lang
manojhans has joined #ruby-lang
manojhans has joined #ruby-lang
ruxpin` has joined #ruby-lang
<ruxpin`>
could someone please elaborate on what's happening here with Array#pack("H*")?
<ruxpin`>
rippa: I read that from the Array docs, but I don't really understand what it does on a byte level
<rippa>
001 == 0x01
<ruxpin`>
rippa: I need to implement same behaviour on another language (unless a bit library exists, and I have trouble finding a proper library without knowing what it actually does)
<rippa>
"#".ord == 35 == 0x23
<rippa>
every two letters are treated as hexadecimal byte
A124 has joined #ruby-lang
<ruxpin`>
"a" packed is "\240"
<ruxpin`>
"A" packed is the same
<ruxpin`>
"b" packed is "\260"
<ruxpin`>
"ab" packed is "\253"
<ruxpin`>
I am puzzled
<rippa>
"a" is 0xA0
TvL2386 has joined #ruby-lang
<rippa>
"b" is 0xb0
<rippa>
"ab" is 0xAB
<ruxpin`>
but "ab".to_i(16) is 171
<ruxpin`>
how it gets to str "\253"
<rippa>
ruxpin`: octal
<rippa>
"ab".to_i(16).to_s(8)
<rippa>
#=>53
<rippa>
*253
<ruxpin`>
oooooh
<ruxpin`>
but what's with the newline (and #Eg too) in the produced packed string?
<rippa>
same
<ruxpin`>
just coincidence that the octal falls in ascii range?
<rippa>
"#" == "\043"
<rippa>
yes
<ruxpin`>
great, thanks. I think I got the gist :)
burns180_ has joined #ruby-lang
weeb1e has joined #ruby-lang
<weeb1e>
Hi everyone
<weeb1e>
Does anyone know why I would be getting this? received ConnectionUnbound for an unknown signature: 7 (EventMachine::ConnectionNotBound)
gnufied has joined #ruby-lang
dous has joined #ruby-lang
<canton7>
weeb1e, try posting the code which reproduces that error
<weeb1e>
canton7: Nevermind, I found the cause, EM just makes it a real pain to pinpoint
<weeb1e>
It was an undefined constant in one of the connections event handler methods
<pw_>
someone on so wrote open-uri is flawed and he suggests to use curb, but thats not well documented
<matled>
pw_: there are different http libraries available or you can just call an external program like curl
quatauta has joined #ruby-lang
<pw_>
matled: thats with %x right?
<matled>
pw_: well, I prefer using a temporary file and curl -sSf to catch the error, but %x should work too
<pw_>
matled: thx can you recommend a lib though? curbs documentation is ...well its hard :-)
<matled>
even though %x is a bit complicated to get right due to shell escape, so I would prefer some method like system or exec which takes the arguments seperately
<matled>
I used curb only once, it seems to have quite good features but I found the documentation not too easy too
<pw_>
matled: k
<matled>
that's the reason why I prefer to call external curl for quick&easy, I already know how to use curl :)
<matled>
pw_: the main problem with this is missing support for connection reusing
<pw_>
matled: thats fantastic, hope you dont mind me using that sometime :-)
<matled>
sure, use it as you like :)
Guest28535 has joined #ruby-lang
PronamChatterjee has joined #ruby-lang
burns180 has joined #ruby-lang
machine2 has joined #ruby-lang
wmoxam_ has joined #ruby-lang
alex_k has joined #ruby-lang
SiliconDon has joined #ruby-lang
manojhans has joined #ruby-lang
tr-808 has joined #ruby-lang
fayimora has joined #ruby-lang
aroop has joined #ruby-lang
ankurgel has joined #ruby-lang
dejongge has joined #ruby-lang
enebo has joined #ruby-lang
burns180_ has joined #ruby-lang
adambeynon has joined #ruby-lang
seanstickle has joined #ruby-lang
Sailias has joined #ruby-lang
AlHafoudh has joined #ruby-lang
ankurgel has joined #ruby-lang
vesan has joined #ruby-lang
darkf has joined #ruby-lang
tekin has joined #ruby-lang
burns180 has joined #ruby-lang
<ankurgel>
nofxx, Hi. You told me about pry (http://pry.github.com/) . I was trying to install it on my machine. Have rvm. Getting this unprecedented error during installation.
<erikh>
so yeah. line 35 runs in a separate thread, but the whole process blocks until line 47 completes. I've verified the proc runs. any reason the global wouldn't be set?
Keva161 has joined #ruby-lang
burns180_ has joined #ruby-lang
lsegal has joined #ruby-lang
jkyle has joined #ruby-lang
<erikh>
rue: sorry to pester; but if you're around...
<erikh>
I'm le stumped
<andrewvos>
:(
<erikh>
that *should* be global and set by the time it gets back
<erikh>
feh
<erikh>
whoa. nevermind
* erikh
continues to fail
<erikh>
throwing a sleep in there fixed it
mssola has joined #ruby-lang
<erikh>
it got the ack before the proc finished.
<erikh>
oh! I know why.
<erikh>
shiiii
flak has joined #ruby-lang
<andrewvos>
wha?
<erikh>
basically I need to keep up on this code
<erikh>
it's a medium-sized base at this point and I'm working on it once a week or so
jaisoares has joined #ruby-lang
<erikh>
but basically the event system there is fire-and-forget
<erikh>
the ack comes back before the message is fully processed
rippa has joined #ruby-lang
jaisoares has quit [#ruby-lang]
<erikh>
there's a feedback loop in there, a message may never complete