<andkerosine>
Is it possible for a splat parameter to take default values?
dhruvasagar has joined #ruby-lang
burns180 has joined #ruby-lang
Heimidal has joined #ruby-lang
Joeysomo has joined #ruby-lang
Joeysomo has joined #ruby-lang
justinxreese has joined #ruby-lang
burns180_ has joined #ruby-lang
<shevy>
andkerosine I tried that recently
<shevy>
def foo(*input = ARGV)
<shevy>
does not seem to work
<shevy>
Mon_Ouie suggested to put the stuff within the method body, but I don't like ARGV within any method body
jredville has joined #ruby-lang
slimfit has joined #ruby-lang
heppy_ has joined #ruby-lang
shtirlic_ has joined #ruby-lang
burns180 has joined #ruby-lang
<andkerosine>
shevy: It seems that's what I'll have to do unfortunately.
<andkerosine>
What's the most convenient way to mix #select with #pop/#shift?
<erikh>
don
<erikh>
don't
looopy has joined #ruby-lang
<erikh>
select is good for pipelines, exploit that and do your mutation in other steps.
<andkerosine>
Fair enough.
<andkerosine>
Hm... actually, I think it might be fitting here.
<andkerosine>
I'm building a request, and it takes a *params argument.
<andkerosine>
A potential set of parameters might be [50, 'hot', 'year', 120000]
<andkerosine>
Which means grab 50 reddit posts sorted by hot and year, and cache the results for two minutes.
<andkerosine>
I'd like to be able to select the first parameter out as the count, and then remove it so that the next match is the cache length, which may or may not be present.
<andkerosine>
I don't know that it's so straightforward.
<erikh>
well if that's what your array looks like...
<andkerosine>
I'm making it harder on me to make it easier for the user. I'd like for them to be able to pass in params pretty much however they choose.
<andkerosine>
So I'm trying to make my code correctly parse out what they're trying to grab.
<andkerosine>
I reckon just taking any integer greater than 1000 to be the cache length is simplest.
<erikh>
unless you're an expert in NLP "however they choose" is a waste of time
<erikh>
it'll also slow down your code
<erikh>
be lazy enough to document your API and point users to it when they have problems.
<erikh>
-- Larry Wall
kek1 has joined #ruby-lang
<andkerosine>
Alas, it's in my nature to mix the two. : /
<andkerosine>
Freedom of expression + guidelines on best practices.
<andkerosine>
That's... sort of the Ruby way, no?
igotnolegs has joined #ruby-lang
machine1 has joined #ruby-lang
<erikh>
people will exploit your documentation no matter what you do
<erikh>
but in the most liberal of interpretations you're describing NP-complete problems at best, and needlessly so
<erikh>
don't try to make the magic formula; just make your library solid and the API will sort itself out
macmartine has joined #ruby-lang
dhruvasagar has joined #ruby-lang
machine1 has joined #ruby-lang
burns180 has joined #ruby-lang
mikeric has joined #ruby-lang
gjaldon has joined #ruby-lang
wmoxam has joined #ruby-lang
Joeysomo has joined #ruby-lang
burns180_ has joined #ruby-lang
Weems has joined #ruby-lang
Weems has joined #ruby-lang
joast has joined #ruby-lang
tomzx has joined #ruby-lang
burns180 has joined #ruby-lang
aza_kibo_ has joined #ruby-lang
rohit has joined #ruby-lang
jkyle has joined #ruby-lang
phlipper has joined #ruby-lang
mistym has joined #ruby-lang
chessguy has joined #ruby-lang
headius has joined #ruby-lang
burns180_ has joined #ruby-lang
tyman_ has joined #ruby-lang
looopy has joined #ruby-lang
wmoxam has joined #ruby-lang
mtkd has joined #ruby-lang
looopy has joined #ruby-lang
DRCALKIN has joined #ruby-lang
bglusman has joined #ruby-lang
burns180 has joined #ruby-lang
fayimora_ has joined #ruby-lang
flebel has joined #ruby-lang
Joeysomo has joined #ruby-lang
Joeysomo_ has joined #ruby-lang
macmartine has joined #ruby-lang
takaokouji has joined #ruby-lang
twittard has joined #ruby-lang
butchanton has joined #ruby-lang
gregmoreno has joined #ruby-lang
burns180_ has joined #ruby-lang
neoesque has joined #ruby-lang
srbaker has joined #ruby-lang
<dhruvasagar>
Utkarsh: there?
Aengus has joined #ruby-lang
fredguest has joined #ruby-lang
Nisstyre has joined #ruby-lang
hagabaka has joined #ruby-lang
burns180 has joined #ruby-lang
solars has joined #ruby-lang
ascarter has joined #ruby-lang
gmurphey has joined #ruby-lang
darkf_ has joined #ruby-lang
bousquet has joined #ruby-lang
savage- has joined #ruby-lang
tyman has joined #ruby-lang
dhruvasagar has joined #ruby-lang
burns180_ has joined #ruby-lang
yxhuvud has joined #ruby-lang
rohit has joined #ruby-lang
x0F_ has joined #ruby-lang
gokul has joined #ruby-lang
srbaker has joined #ruby-lang
dhruvasagar_ has joined #ruby-lang
tudorstudio has joined #ruby-lang
brownies has joined #ruby-lang
deryldoucette has joined #ruby-lang
burns180 has joined #ruby-lang
butchanton has joined #ruby-lang
langbiangplaza has joined #ruby-lang
langbiangplaza has joined #ruby-lang
uniqanomaly has joined #ruby-lang
heppy has joined #ruby-lang
burns180_ has joined #ruby-lang
langbiangplaza has joined #ruby-lang
Heimidal has joined #ruby-lang
wyhaines has joined #ruby-lang
havenn has joined #ruby-lang
burns180 has joined #ruby-lang
srbaker has joined #ruby-lang
brianpWins has joined #ruby-lang
machine1 has joined #ruby-lang
achiu has joined #ruby-lang
rippa has joined #ruby-lang
burns180_ has joined #ruby-lang
csherin has joined #ruby-lang
davidw has joined #ruby-lang
TvL2386 has joined #ruby-lang
<TvL2386>
hi guys,
justinmcp has joined #ruby-lang
Luxx_ has joined #ruby-lang
Z33K|Lux has joined #ruby-lang
burns180 has joined #ruby-lang
solars has joined #ruby-lang
<TvL2386>
hi guys, I'm having problems with nokogiri. On my development machine it works perfectly and on my production machine it does not. I'm using bundler to maintain gem versions and I am using ruby-1.9.3p125. A little script to simulate is here: http://pastie.org/3510031 The output on dev/prod differ (shown in comments in the pastie)
Natch has joined #ruby-lang
mikeric has joined #ruby-lang
mikeric has joined #ruby-lang
tbuehlmann has joined #ruby-lang
ezkl has joined #ruby-lang
burns180_ has joined #ruby-lang
kek1 has joined #ruby-lang
<Defusal>
anyone ever use X-Accel-Redirect with nginx?
thrcka has joined #ruby-lang
<TvL2386>
darn, I needed to do data.encode!("utf-8","ISO-8859-1") for some reason I don't understand. Guess it has something to do with default encoding differences on the 2 boxes?
postmodern has joined #ruby-lang
mikeric has joined #ruby-lang
Natch| has joined #ruby-lang
pemeon has joined #ruby-lang
burns180 has joined #ruby-lang
<Mon_Ouie>
That means "encode from UTF-8 to ISO-8859-1"
adambeynon has joined #ruby-lang
adambeynon has joined #ruby-lang
<TvL2386>
Mon_Ouie, that's obvious, but why does it have to be done on production to get it to function the same as development?
<TvL2386>
Also, anyone here familiar with ruby-inotify?
flebel has joined #ruby-lang
kitallis has joined #ruby-lang
burns180_ has joined #ruby-lang
francisfish has joined #ruby-lang
gentz has joined #ruby-lang
tekin has joined #ruby-lang
amerine has joined #ruby-lang
<Mon_Ouie>
I'd guess locales may be different on those machines
<Mon_Ouie>
Which would change the default encoding
burns180 has joined #ruby-lang
uniqanomaly has joined #ruby-lang
rohit has joined #ruby-lang
toretore has joined #ruby-lang
kp666 has joined #ruby-lang
thrcka has joined #ruby-lang
burns180_ has joined #ruby-lang
<Stereokitsune>
Hello.
<Stereokitsune>
I forgot how this piece of shit^Wcode may be optimized:
<PatrixCR>
guys, what's the difference of cucumber, rspec, capybara, and selenium?
burns180 has joined #ruby-lang
mssola has joined #ruby-lang
manojhans has joined #ruby-lang
looopy has joined #ruby-lang
apeiros_ has joined #ruby-lang
rob_ has quit [#ruby-lang]
jamw has joined #ruby-lang
burns180_ has joined #ruby-lang
FortKnox has joined #ruby-lang
csherin has joined #ruby-lang
manojhans has joined #ruby-lang
benanne has joined #ruby-lang
andkerosine has joined #ruby-lang
<andkerosine>
If the method signature is something like def inbox(folder = 'inbox', count), how does one go about making it so that inbox(5) doesn't pass 5 to the folder argument?
<andkerosine>
I imagine it involves having the single argument be a splat and then parsing out the values?
publicvoid__ has joined #ruby-lang
<PatrixCR>
inbox nil, 5
<andkerosine>
Yep, unpleasant for the user.
<PatrixCR>
inbox 'inbox', 5
<andkerosine>
Redundant.
<PatrixCR>
switch the argument position, then
m3nd3s has joined #ruby-lang
<andkerosine>
That's counter-intuitive.
<andkerosine>
I don't mind sacrificing a bit of programmer pleasantness to increase user pleasantness.
<andkerosine>
Just wondering if there was a non-splat way to do it.
<PatrixCR>
inbox count: 5
<PatrixCR>
inbox :count => 5
<andkerosine>
All viable options, of course, but they don't maximize user pleasantness, which is my primary aim.
<dominikh>
then you're doomed, because those are your only options.
<andkerosine>
Not at all.
<andkerosine>
A splat works fine.
<dominikh>
which is one of the mentioned options. so use it?
<andkerosine>
This was a question of curiosity, not a dead end.
<andkerosine>
Why is the pursuit of surplus knowledge so frowned upon?
<dominikh>
it's not, ignoring "there is no other way" is.
<dominikh>
change the order, explicitly pass nil, use a hash, use a splat. those are your options.
<dominikh>
if you don't like any of these, bad luck.
<andkerosine>
Duly noted.
<andkerosine>
I thought there might be some clever Ruby approach to matching on argument types.
<andkerosine>
Would any of that be considered "bad practice"?
<apeiros_>
yes
<apeiros_>
see Enumerable#find
<andkerosine>
Just... to avoid the subscripting?
<apeiros_>
and: eeeeew!
<Mon_Ouie>
p.to_i == p ?
<andkerosine>
To pull out the count.
<apeiros_>
.is_a?(String), (Integer)
<apeiros_>
but still, horrible
<andkerosine>
Same thing.
<Mon_Ouie>
I'd just have a fixed order
<Stereokitsune>
Is there the better way to replace symbols &, <, > and other ones into HTML sequences (like &) except of manual composing of hundred regexps?
<Mon_Ouie>
Stereokitsune: CGI.escape_html
<apeiros_>
it's actually one regexp @ Stereokitsune
<apeiros_>
and Mon_Ouie means escapeHTML (bad bad form in stdlib :-S)
<Mon_Ouie>
Nope
<Mon_Ouie>
Both work
<apeiros_>
oh? they've added a sane one?
<apeiros_>
good to know. *takes not to refactor all .escapeHTML in his code*
<Stereokitsune>
Thank you.
<PatrixCR>
and: do you use ruby 1.9?
<andkerosine>
Well, I'd also like to support 1.8.7 in this case.
<PatrixCR>
Hm. In ruby 1.9.3 in my machine, I create a method just like you wrote, and when I call inbox 5, the count parameter has the value 5, and folder is 'inbox'
manojhans has joined #ruby-lang
<PatrixCR>
maybe ruby 1.8 doesn't support it?
<andkerosine>
Huh...
<andkerosine>
I could /swear/ I tested that.
thone_ has joined #ruby-lang
manojhans has joined #ruby-lang
burns180 has joined #ruby-lang
<andkerosine>
PatrixCR: Thanks. Alas, syntax error in 1.8.
rohit has joined #ruby-lang
<shevy>
hehe
rob_ has joined #ruby-lang
<rob_>
hi
wyhaines has joined #ruby-lang
<rob_>
if i have class that inherits from Hash, how can i load the value of another hash into the class?
workmad3 has joined #ruby-lang
<apeiros_>
rob_: you mean into an instance of your class?
<dominikh>
(or method_missing + respond_to? if you do not want to explicitly say which methods should forward)
havenn has joined #ruby-lang
imperator has joined #ruby-lang
looopy has joined #ruby-lang
future_chimp has joined #ruby-lang
solars has joined #ruby-lang
PatrixCR has quit [#ruby-lang]
chessguy has joined #ruby-lang
burns180 has joined #ruby-lang
chimkan has joined #ruby-lang
theoros has joined #ruby-lang
chimkan_ has joined #ruby-lang
ezkl has joined #ruby-lang
sandbags has joined #ruby-lang
wyhaines has joined #ruby-lang
seanstickle has joined #ruby-lang
darkf has joined #ruby-lang
<ezkl>
Working on a gem (https://github.com/ezkl/sniffles) and can't figure out why a local install via Bundler's gemtasks works, but not if I release to Rubygems and install. Specs pass locally and on Travis. Anyone feel like lending me a fresh set of eyes?
francisfish has joined #ruby-lang
<dominikh>
ezkl: define "doesn't work".
<dominikh>
because it installs fine
francisfish has joined #ruby-lang
<ezkl>
dominikh: Sorry. Method calls that work in both the specs and when the gem is installed locally, fail to work if installed from Rubygems. I'll post a gist.
brownies has joined #ruby-lang
dous has joined #ruby-lang
Spooner has joined #ruby-lang
burns180_ has joined #ruby-lang
<andkerosine>
ezkl: Are you getting NoMethodErrors?
Sailias|work has joined #ruby-lang
<ezkl>
andkerosine: I'm getting internal exceptions that should occur only if a scan of a directory glob fails to return matches. I tried to get creative with eval, so I'm guessing it is Path-related.
<andkerosine>
That was my assumption.
<ezkl>
andkerosine: I'm just a bit suprised that specs pass on my machine and on 1.8.7-1.9.3@Travis
<andkerosine>
Then surely it's an include problem?
srbaker has joined #ruby-lang
<ezkl>
andkerosine: That is what I've been assuming, but I haven't been able to identify where. Apparently, I should avoid trying my hand at meta-programming after midnight.
<andkerosine>
This is gospel. : )
Joeysomo_ has joined #ruby-lang
jxie has joined #ruby-lang
darkf_ has joined #ruby-lang
<ezkl>
andkerosine: I just created a fresh gemset. Cloned the repo, checked out a tag I pushed to Rubygems, ran Bundler, and `bundle exec rake install` and it is working. I'm going to try installing the same version via gem install on another clean gemset.
<andkerosine>
What would it have been interacting badly with?
tomb has joined #ruby-lang
virunga has joined #ruby-lang
QaDeS has joined #ruby-lang
<ezkl>
andkerosine: No idea, but I've had subtle weirdness caused by RVM and $PATH disagreements in the past. Also, much more relaxing than looking at the same hundred lines of code again.
havenn has joined #ruby-lang
<ezkl>
Yeah, same issue as before with the fresh gemset.
<dominikh>
ezkl: and you're sure that the gem isn't missing files that your library actually uses and has in the git repo?
<ezkl>
dominikh: I've checked and everything appears intact.
<dominikh>
ezkl: so, I just installed the gem, what do I do now.
<ezkl>
dominikh: Yeah, same here. If you run `Sniffles.sniff(response.body, :wordpress)` you'll get an UnknownSniffer exception that is raised if the library is unable to find ./lib/sniffles/sniffers/cms/wordpress.rb
looopy has joined #ruby-lang
chimkan__ has joined #ruby-lang
<ezkl>
dominikh: If I open the installed gem in an editor, that file is there.
<dominikh>
ezkl: yeah, that obviously will not work.
<ezkl>
andkerosine: I knew it was something incredibly stupid.
<ezkl>
er
<ezkl>
dominikh
<dominikh>
heh
Sailias_ has joined #ruby-lang
fayimora has joined #ruby-lang
<ezkl>
dominikh: Same username on github? I'd like to give you credit in the commit.
<dominikh>
ezkl: yup
gregf has joined #ruby-lang
<ezkl>
dominikh: Cool. Thanks again. I can't believe I A) wrote and B) repeatedly glossed over those methods.
<dominikh>
heh
<dominikh>
don't worry, me neither :P
burns180 has joined #ruby-lang
fayimora_ has joined #ruby-lang
gmurphey_ has joined #ruby-lang
dous has joined #ruby-lang
chimkan has joined #ruby-lang
canton7 has joined #ruby-lang
pw_ has joined #ruby-lang
kyrylo has joined #ruby-lang
kyrylo has joined #ruby-lang
gouthamvel has joined #ruby-lang
jasonw22 has joined #ruby-lang
gouthamvel has quit ["WeeChat 0.3.0"]
burns180_ has joined #ruby-lang
mark_locklear has joined #ruby-lang
wallerdev has joined #ruby-lang
gasbakid has joined #ruby-lang
rippa has joined #ruby-lang
t4nk524 has joined #ruby-lang
<t4nk524>
pastie:hi
gnufied has joined #ruby-lang
<andkerosine>
So... avoid inheritance where possible.
<andkerosine>
I need a Config object that's basically just a Hash, except that it writes itself to a file whenever a value changes.
<andkerosine>
@config is a JSON object, and everything works fine for one-dimensional stuff.
<andkerosine>
But how do I make @config.[]= work for multiple dimensions?
fayimora has joined #ruby-lang
wwalker has joined #ruby-lang
<wwalker>
recommendations for a tool for 1) making CLIs 2) making a project directory with "all the right stuff" (rakefile skeleton, lib, src, doc )
<andkerosine>
OptParse for CLIs.
<andkerosine>
Jeweler or Bundler for gem scaffolds.
<Mon_Ouie>
Alternatively, you could use Slop for option parsing
<dominikh>
slop++
<wwalker>
thank you. I'll look at slop and OptParse.
<wwalker>
what about a tool that builds a reasonable default rakefile and project hieracrhy? My Rakefile fu (and knowledge of gem building and bundler) is weak
shyouhei_ has joined #ruby-lang
<Mon_Ouie>
Depends on what you'd want as a default Rakefile
<Mon_Ouie>
I sometimes don't even create one
tbuehlmann has joined #ruby-lang
<wwalker>
Mon_Ouie: in the end I'd want to be able to run rake {test,gem}. I could just copy one, but I remember from differenct conferences people talking about tools that built a deafult hierarchy with some default file to start from. One was targeted at CLI tools, and I saved it in a file on my notebook, and can't find that file...
looopy has joined #ruby-lang
burns180 has joined #ruby-lang
<wwalker>
gli ! (found the file :-) anyone used it?
<Mon_Ouie>
I use gem build *.gemspec to build the gem, and rake :test do ruby "test/run_all.rb" end for tests, just so automated tools can run the test suite
<wwalker>
Mon_Ouie: thanks
wmoxam has joined #ruby-lang
dhruvasagar has joined #ruby-lang
pemeon has joined #ruby-lang
mistym has joined #ruby-lang
burns180_ has joined #ruby-lang
jacobwg has joined #ruby-lang
gmurphey has joined #ruby-lang
jacoby has joined #ruby-lang
pw__ has joined #ruby-lang
cyri_ has joined #ruby-lang
wallerdev has joined #ruby-lang
burns180 has joined #ruby-lang
<jacoby>
Can anyone give me a pointer related to class_eval?
<any-key>
ruby doesn't use pointers
<jacoby>
s/pointers/help/
Nisstyre has joined #ruby-lang
<jacoby>
Never mind. I think I got it
ankurgel has joined #ruby-lang
<ankurgel>
In a method, use of statement like: return 1 if x==2
<ankurgel>
else return 0
<ankurgel>
valid?
<wwalker>
Am I the only ruby dev that uses ri?
<bougyman>
could be
<Mon_Ouie>
Nope
<ankurgel>
bougyman, Mon_Ouie Why?
<bougyman>
why what?
<ankurgel>
was that for wwalker ?
<Mon_Ouie>
Yep
<bougyman>
yesh
<Mon_Ouie>
And the yep was for you :p
<ankurgel>
oh
<ankurgel>
Mon_Ouie, Oh. :D
<Mon_Ouie>
ankurgel: You need an end
<ankurgel>
that is after the method return statements, right?
<Mon_Ouie>
The syntax is if condition; expression; else; expression; end
<ankurgel>
I was basically dubious for use of conditionals that way.
<ankurgel>
return 1 if x==2
<ankurgel>
else return 2
<ankurgel>
valid?
<ankurgel>
ofcourse, end at the end of it to end the method.
<Mon_Ouie>
You can't have an else clause with a postfix if condition
chimkan has joined #ruby-lang
<wwalker>
Mon_Ouie: he can't put them on separate lines if he puts the if action before the if
<wwalker>
that terminates the if at the end of the line doesn't it?
<ankurgel>
wwalker, Mon_Ouie Then, only correct way is : if expression; return 1; else; return 0
<ankurgel>
?
<Mon_Ouie>
Well, it's never the only way
<ankurgel>
wwalker, that
<ankurgel>
Mon_Ouie, course. :)
<Mon_Ouie>
And you still miss the return
<wwalker>
ankurgel: if you want a shorter version, which seems to be what you are looking for...
<Mon_Ouie>
Not to end the method that expression is part of, but to end the if expression
<wwalker>
return (x==2) ? 0 : 1
<wwalker>
or
<ankurgel>
aah, yes, ternary!
<Mon_Ouie>
return (if x == 2 then 0 else 1 end)
<wwalker>
return if (x==2) 1; else 2; end
<ankurgel>
got it!
<wwalker>
Mon_Ouie's looks micer (and I didn't test my syntax)
<ankurgel>
You guys are awesome Mon_Ouie , wwalker !
<wwalker>
nicer
<ankurgel>
trying that out.
<wwalker>
btw, for anyone interested, gli is looking quite nice for building command line tools.
dejongge has joined #ruby-lang
carlosed has joined #ruby-lang
heppy has joined #ruby-lang
ged has joined #ruby-lang
burns180_ has joined #ruby-lang
<andkerosine>
ankurgel: Ternary might be overkill for what you're doing.
<andkerosine>
return 0 if x == 2
<andkerosine>
And then just return 1
<andkerosine>
No need for the else clause because it's implicit in this case.
<ankurgel>
andkerosine, I basically was trying to make a method for palindrome
<ankurgel>
on suggestion of Mon_Ouie and wwalker , framed this :
<ankurgel>
return (if string.downcase.eql?(string.downcase.reverse)==true then true else false end)
<andkerosine>
Determining if two strings are palindromes?
<ankurgel>
if *a* string is a palindrome
<andkerosine>
Ah.
<andkerosine>
Um...
<ankurgel>
def palindrome?(string)
<ankurgel>
return (if string.downcase.eql?(string.downcase.reverse)==true then true else false end)
<ankurgel>
end
<Mon_Ouie>
ankurgel: You realize that then true else false is completely redundant?
<ankurgel>
andkerosine, Can you please elaborate on that are_anagrams thing?
<ankurgel>
sounds interesting.
<andkerosine>
I was asking you to write a method that returns whether or not two words are anagrams.
<andkerosine>
Just to test that you /get/ the various things we've discussed here.
<ankurgel>
ok, so how do I verify the combination there?
<andkerosine>
That's... sort of the whole point? : )
<ankurgel>
^ this does the job?
<ankurgel>
:O
morozovm has joined #ruby-lang
looopy has joined #ruby-lang
<andkerosine>
No, the ellipsis is not a Ruby anagram operator, though that would be interesting...
<andkerosine>
So... to check that a word is a palindrome, you simply return whether or not it is the same backwards and forwards.
<andkerosine>
How do you determine if two wards are anagrams?
<andkerosine>
*words
<ankurgel>
Okay. Finally it made sense to me. You want me to write code at that place to check whatever we discussed here.
<andkerosine>
Well, to check if two words are anagrams.
<ankurgel>
hm
<andkerosine>
But, in doing so, you would prove your grasp of the discussed topics.
<ankurgel>
that can be done!
<andkerosine>
It most certainly can.
<ankurgel>
I can sort them alphabetically
<ankurgel>
then,
<ankurgel>
I can test for equality
<andkerosine>
Huzzah!
<ankurgel>
^this is approval?
<ankurgel>
:)
<andkerosine>
Very much so.
<ankurgel>
YESS!!
<andkerosine>
It doesn't "click" like that for everybody.
<ankurgel>
string.sort will work?
<andkerosine>
I've seen people iterate over each word and keep a count of the letters they've seen.
<andkerosine>
Ah, almost.
<andkerosine>
A String is a single object, so sorting it doesn't make much sense.
<andkerosine>
How to get it into sortable pieces?
<ankurgel>
I have been using ruby for a while. But, not fluent in practice. Gap comes because of involvement in college stuff.
<ankurgel>
but, always great to read and do it again.
<ankurgel>
#ruby-lang is amazing!
<andkerosine>
Being able to program, in any language, really, is just such an empowering thing.
<ankurgel>
andkerosine, sorting in pieces? as in ?
<andkerosine>
Well, if you're going to sort something, there obviously has to be more than one "piece". But a String like 'cba' to Ruby looks like one "piece", even though we humans see it as three pieces.
<ankurgel>
oh.
<ankurgel>
I can fragment a string into individual characters..
<ankurgel>
push them in array.
<ankurgel>
and then sort it.
<ankurgel>
that way, not one 'piece'.
<andkerosine>
Once again, spot-on.
<andkerosine>
However, no need to do any array pushing.
<ankurgel>
then?
<andkerosine>
Ruby's #split will turn a string into an array of characters.
<ankurgel>
yes yes yes yes
<ankurgel>
I remember something about this thing.
<andkerosine>
That's how it works in most languages, I think.
<ankurgel>
I used it to split along spaces
<andkerosine>
Mm-hmm.
<ankurgel>
I mean, to break word from a sentence.
<ankurgel>
s/words/words
<ankurgel>
I'll have to use char regexp along with split then?
<andkerosine>
Not even that much.
<andkerosine>
What is it that we want to split on?
<ankurgel>
"ankurgel".split(/[a-z]/) ?
<andkerosine>
Hm... it works, but still overkill. : )
<ankurgel>
tried it now after writing here.
<ankurgel>
not working. :/
<andkerosine>
?
<ankurgel>
but why is that. It seems right to me.
<ankurgel>
no?
<andkerosine>
I don't do much splitting, but that is how I've always assumed it would work, yes.
<andkerosine>
ankurgel: Are you familiar with the \b and \w flags?
<ankurgel>
no
<andkerosine>
Ah.
<ankurgel>
what sort of flags are they?
<ankurgel>
and what does /b./ exactly denote here?
<Mon_Ouie>
\b isn't the same as b
<andkerosine>
/b./ means find the letter "b" followed by anything.
<ankurgel>
yes. regexp way.
<ankurgel>
\b is escaped,
<ankurgel>
so it must denote something
<Mon_Ouie>
\b matches at points that mark the boundaries of a word
<Defusal>
ohh i see
<Defusal>
i used a hack when i needed to do it last year
<ankurgel>
points to start boundary or end boundary?
<Defusal>
because i couldn't come up with a better solution at the time
<Defusal>
ended up defining const_missing in the class
<Defusal>
i guess thats not the of the world, if theres no better way
<Mon_Ouie>
It's a 0-width match, though, so matching the next character is needed if you want to replace something
<ankurgel>
/\b./ so it points to first char of word
<andkerosine>
Spot-ons: 3. : P
<ankurgel>
and /\w/ points entire word instead, so all uppercase.
<andkerosine>
Not quite.
Bwild has joined #ruby-lang
<ankurgel>
and /\b/ points to nothing except boundary
<ankurgel>
andkerosine, why?
<ankurgel>
it extracts whole word, no?
<andkerosine>
\w is a flag to match "word characters".
<ankurgel>
or each char of word?
<andkerosine>
Things like letters and numbers.
<ankurgel>
i see..
<ankurgel>
making some sense.
<andkerosine>
/\w/ =~ '.,%^'
<andkerosine>
# => nil
<andkerosine>
Because it didn't find any "word-like" characters.
<Mon_Ouie>
ankurgel: \b actually matches both end and begin of the word
<Defusal>
ah right, const_missing is probably the best way anyway, since even if i did add the first modules constants to the second module, i would have to remove and recreate the reference whenever the first module is reloaded
<andkerosine>
So /.\b/ to capitalize the last character of a word.
<ankurgel>
Mon_Ouie, but it can't at a single point of time.
<ankurgel>
oh
<andkerosine>
Well, to match, not necessarily capitalize.
<ankurgel>
So, it's like </ and />
<Defusal>
i just get the feeling that const_missing is not very good for performance
<andkerosine>
Depends on how often you're going to make Ruby traverse, of course.
<Mon_Ouie>
But since the character after the end is always a non-word character, capitalizing it never does anything
<ankurgel>
andkerosine, NICE. that example was good.
<ankurgel>
reading it again.
<Mon_Ouie>
Which is why it can be ignored in your gsub expression
<andkerosine>
=~ is an excellent way to get your Regexp bearings.
<andkerosine>
String =~ Regexp, or Regexp =~ String.
<andkerosine>
For testing all of the options and whatnot.
<ankurgel>
it is used to test against a regexp right?
<Defusal>
andkerosine, yup, well whenever referring to the models that are mixed into a module
<ankurgel>
.match can also be used , I think.
<yxhuvud>
defusal: usually, it is not evaluated many times, since contants tend to be, well, constant
<andkerosine>
Indeed.
<andkerosine>
#match will provide much more thorough data.
<Defusal>
the point is to keep the models out of the top level namespace
<andkerosine>
=~ simply returns the index at which the first match was found.
<ankurgel>
so, usage wise =~ is more handy!
<Defusal>
so i am reading the model code manually and evaluting it with a new Module instances binding
<andkerosine>
ankurgel: For quick tests, definitely.
<ankurgel>
cool!
<andkerosine>
For more complex patterns, though, you may want to use #match to see exactly what's being captured.
<Defusal>
then const_missing will look through the modules when it needs a model constant
achiu has joined #ruby-lang
<ankurgel>
andkerosine, [,`!"`] are counted as non-word characters?
<andkerosine>
Mm-hmm.
<andkerosine>
Any punctuation.
<ankurgel>
testing.
<andkerosine>
I believe \w is just a shortcut for [A-Za-z0-9]
francisfish has joined #ruby-lang
<Mon_Ouie>
Depends on Ruby version
<andkerosine>
Mm-hmm.
<ged>
andkerosine: And '_'.
<ankurgel>
andkerosine, " is still counted in it I think.
<Mon_Ouie>
In 1.8, it can match UTF-8 word characters with appropriate regexp flags
<ankurgel>
how do I test it ?
<andkerosine>
/\w/ =~ '"' == nil
<Mon_Ouie>
In 1.9, it's what you said + _, as ged said
<andkerosine>
ankurgel: The first one worked on my end.
<andrewvos>
Damnit I got to leave in 20 minutes
<ankurgel>
andkerosine, on 1.9.2?
<andrewvos>
I wanted to put it on heroku but I guess a cron job could work
<andkerosine>
1.9.3
<andkerosine>
Heroku + cron.
<andkerosine>
ankurgel: Works on 1.8.7, too, so I think you may've mistyped?
tomzx has joined #ruby-lang
<ankurgel>
andkerosine, must have.
<ankurgel>
andkerosine, I am trying one thing here now. Coming back with problem in it, soon. :D
<andkerosine>
Problems beget solutions. : )
<andrewvos>
<3 heroku
Z33K|Lux has joined #ruby-lang
<andrewvos>
Please don't put that on ShitRubyistsSay ^
<andkerosine>
s/Shit/BeautifullyTrueThings
<andrewvos>
haha
<andrewvos>
Ok cronjob setup
<andrewvos>
Damn the heroku scheduler makes me happy
<ankurgel>
andkerosine, YEAH. I was trying to improve that palindrome thing. Such that a string like: "Madam, I'm Adam!" is treated as palindrome too.
<andkerosine>
Nice!
<ankurgel>
that is it will disregard all spaces, and punctuations etc.
<andkerosine>
Mm-hmm.
<ankurgel>
first, I did.
<ankurgel>
string.downcase!
<ankurgel>
then,
<ankurgel>
string.gsub(/\W/){|m|}
<ankurgel>
result:
<ankurgel>
madamimadam
<andkerosine>
Ah, negative.
<andkerosine>
Oh, it did work?
<ankurgel>
yes, it did.
<andkerosine>
Mm-hmm.
<andkerosine>
But you don't need the block syntax for that use case.
<ankurgel>
Why, negative? Where did I do wrong?
<andkerosine>
string.gsub(/\W/, '')
<andkerosine>
Replace non-word characters with nothing.
<ankurgel>
I can simply substitute by this way also?
<ankurgel>
cool!
<andkerosine>
Well, yeah, but it's slightly less efficient and also just the "not right" way to do it, so to speak.
<ankurgel>
noting it down.
<andkerosine>
The block syntax is for manipulating captures.
<andkerosine>
You're not capturing anything (with parentheses), so |m| is blank, thus the intended effect.
minsa has joined #ruby-lang
<ankurgel>
:) Ok
<andkerosine>
Just a heads-up.
<ankurgel>
was really needed. :)
<andkerosine>
It seems like something that would have the potential to trip you up down the road, so I figured I'd point it out.
<ankurgel>
wait..
<ankurgel>
I didnt' get that point completely.
havenn has joined #ruby-lang
<ankurgel>
I mean,
<ankurgel>
should I refrain from using empty blocks?
<andkerosine>
Oh, yes.
<andrewvos>
andkerosine: yeahhh
<andrewvos>
definitley
<andrewvos>
err I mean ankurgel
<andkerosine>
Heh.
<ankurgel>
andkerosine, andrewvos But, why? o.O
<andkerosine>
I mean, think about it, what purpose could an empty block possibly serve? : )
<andrewvos>
andkerosine: Cause it just looks stupid?
<andkerosine>
It makes Ruby do a little extra work, and for no real reason.
<ankurgel>
non-required iteration. gotcha.
<andkerosine>
#gsub can behave several different ways, which is common in Ruby, but you want to make sure you're using the right format for the task.
<ankurgel>
hm
<andkerosine>
ankurgel: Nailed it.
<andkerosine>
#gsub's block syntax is amazing, but you should only use it when you need it.
<ankurgel>
andkerosine, what if I wanted the space to remain there and every other punctuation to be removed?
<andkerosine>
Because you just want to /remove/ certain characters, the #gsub(old, new) format suffices.
<ankurgel>
Certainly modification of regexp must be required.
<andkerosine>
Match on /[\w ]/
<ankurgel>
andkerosine, yes. :) and that's even more handy!
<andkerosine>
Essentially, you want word characters and spaces, so rather than jumping through hoops, just tell the parser you want word characters and spaces. : D
<ankurgel>
can I chain method like: string.downcase!.gsub! .. ?
<andkerosine>
Certainly.
<andkerosine>
No need for the !, though.
<ankurgel>
But, I want the changes to made it in string itself.
<ankurgel>
first downcase and then substitution.
<ankurgel>
so. method chaining will work that way ? (by use of !) ?
burns180_ has joined #ruby-lang
<andkerosine>
Hm, this is sort of tricky to describe "cleanly", but basically, if you're chaining, there's no need to modify the object in place, because you're still passing along the modified value within the chain.
<ankurgel>
Dont' want to use string = string.downcase.gsubs!...
<ankurgel>
andkerosine, ^
<andkerosine>
Huh.
<andkerosine>
I don't know where my misconception came from. : /
<andkerosine>
My apologies for misleading.
<andkerosine>
! all the way, although I still don't quite understand why that is.
<nofxx>
Hehe.. is only here that apache.org is off ?
<ankurgel>
andkerosine, ?
<ankurgel>
trying
<ankurgel>
worked now.
<ankurgel>
but, again, why?
<nofxx>
maybe it's because it's running.... apache! =D with java on top
<bougyman>
CRAPache
<andkerosine>
Alas, I don't know.
<nofxx>
bougyman, heheh.... need an alternative to 'ab'
<andkerosine>
My understanding was that string.downcase.gsub! would work because downcase is passing the string object itself to gsub!, but apparently not...
<bougyman>
nofxx: siege
<shevy>
bougyman: counter-siege!
<andkerosine>
Well, yeah, it makes sense.
<andkerosine>
#downcase just returns a modified string, so the object isn't passed to #gsub!.
<andkerosine>
In short, yes, ! in chains to modify in-place.
<nofxx>
cool! thanks bougyman shevy , found
<andkerosine>
And, again, sorry for taking us down this winding road to confusion.
<ankurgel>
downcase returns the modified string, yes.
<ankurgel>
but that is passed to gsub!
<ankurgel>
which actually modifies string
<ankurgel>
should be like this only.
<andkerosine>
Well, no.
<andkerosine>
#gsub! is just receiving /a/ string object, in that case, not /the/ string object.
<ankurgel>
I mean, an array back as a single entity?
<andkerosine>
Well, yes.
<nofxx>
More like swiss army knives! same color too
<andkerosine>
Goes through every array element and only returns true if all elements are "true".
<andkerosine>
[1, 5, 'bacon', 10, nil].all? == false because of the nil.
blowmage has joined #ruby-lang
<ankurgel>
oh.
<ankurgel>
but, why check that?
<andkerosine>
Hm?
<ankurgel>
there must be no nil there.
<andkerosine>
Right, no, that was just a demonstration of how it's used.
<ankurgel>
:) okay
<andkerosine>
In the case of are_anagrams, I'm using #all? on the map to ensure that every element is equal to the first, which will only be true if all the passed arguments are anagrams of each other.
<andkerosine>
Note that #map would not have been sufficient.
<ankurgel>
I'll look it again. In middle of some other snippet. :)
<ankurgel>
separated as in, change on one doesn't inflict change on another.
<shevy>
ankurgel .dup on string
<andkerosine>
str = string.dup
<ankurgel>
okay
<ankurgel>
dup denotes ?
<andkerosine>
There are pretty much an infinite amount of ways to do it (as long as you change the object in some way, it will pass by value), but #dup is the cleanest and makes the most semantic sense.
<andkerosine>
Hm... we'd have to get into passing by value and passing by reference. Maybe you know them from C++?
<ankurgel>
yes.
<ankurgel>
so, earlier analogy followed passing by reference.
<ankurgel>
but dup forces copy of object.
burns180_ has joined #ruby-lang
<ankurgel>
and thus pass by value?
<andkerosine>
Precisely.
<andkerosine>
As soon as you do anything to the right side, it becomes a new object, and thus only the value is passed.
<ankurgel>
Oh. so, basically dup doesn't chagne anything, only returns back the object.
<ankurgel>
but that object is now treated as another object
<ankurgel>
which is copied into lvalue
<andkerosine>
Specifically /not/ the object.
<ankurgel>
and thus, seperated out.
<andkerosine>
Just the value.
<ankurgel>
ok :)
<ankurgel>
see this, str=str.downcase.gsub(/\W/,'')split
<ankurgel>
doing same, downcasing, then removing every space, punctuation etc and then splitting.
<ankurgel>
but, I want here to keep space intact,
<ankurgel>
so that it can split from spaces in last method chain
<andkerosine>
So, rather than splitting on non-word characters, you'll have to use a character class.
<ankurgel>
can't use ^/\W/ as it will denote at "starting of line" and not 'NOT'
<andkerosine>
Right.
<andkerosine>
^ is start of line unless it's inside a character class, [], which then takes on the NOT meaning.
<ankurgel>
yes
<andkerosine>
[^a-z] will match anything but lowercase letters.
m3nd3s has joined #ruby-lang
<andkerosine>
Ruby's Regexp engine supports a /lot/ of character classes.
<ankurgel>
hm
<ankurgel>
str.downcase.gsub([^a-z ]*).split ?
<ankurgel>
added space in there, because have to exclude that too.
<ankurgel>
space will make split possible later.
havenn has joined #ruby-lang
<andkerosine>
No need for the *?
<ankurgel>
but, multiple characters?
<ankurgel>
for a word formation
<ankurgel>
or a sentence formation to be precise excluding punctuation marks
<andkerosine>
It will find all of them regardless.
<andkerosine>
#gsub will go and go until the string no longer contains any of the characters you want to remove.
<ankurgel>
got it. ;)
<andkerosine>
Of course, you're not trying to remove lowercase letters.
<ankurgel>
It is the first time I'm actually participating in this much long discussion at #ruby-lang
<ankurgel>
always used to remain idle
<andkerosine>
Here be learning treasures.
<andkerosine>
Okay, well, you see what's happening, right?
<ankurgel>
yes,
<ankurgel>
I sorted, joined back.
<ankurgel>
so, I have the structure made up.
<ankurgel>
few things left at end.
<ankurgel>
but they are bamboozling
<ankurgel>
that is what paused me.
<eggman2001>
is there a way for me to do text + variable to reference another variable?
<andkerosine>
Ack, I don't want to show you my solution just yet, but the solution likely requires a few things you might not know...
<andkerosine>
eggman2001: Symbols.
<ankurgel>
hm
macmartine has joined #ruby-lang
<andkerosine>
Otherwise you unnecessarily introduce #eval-ish methods.
<eggman2001>
for example, var1 = 123; a = 1; so var + a in some way
<andkerosine>
:var1 = 123
<andkerosine>
:"var#{a}"
<ankurgel>
andkerosine, should I create an hash up there as well?
Bwild has joined #ruby-lang
<ankurgel>
relating sorted element and original element.
<eggman2001>
andkerosine: that just returns a string
<eggman2001>
it returns the string "var1"
<andkerosine>
Which Ruby are you on?
<eggman2001>
1.9.3
<andkerosine>
1.9.3p0 :006 > a = 1
<andkerosine>
=> 1
<andkerosine>
1.9.3p0 :007 > :"var#{a}"
<andkerosine>
=> :var1
<andkerosine>
Admittedly, I don't think symbols can be declared globally, so you'll likely have to use a hash to store your variables...
<eggman2001>
I want it to return the value of var1. so I'd like it to return 123
<andkerosine>
But it's how to do it if you don't want to get into eval ickyness.
rue has joined #ruby-lang
<eggman2001>
okay thanks
<andkerosine>
1.9.3p0 :008 > vars = {var1: 123}
<andkerosine>
=> {:var1=>123}
<andkerosine>
1.9.3p0 :009 > a = 1
<andkerosine>
=> 1
<andkerosine>
1.9.3p0 :010 > vars[:"var#{a}"]
<andkerosine>
=> 123
<eggman2001>
wow that's pretty ugly :p
<andkerosine>
Alas, alas.
<eggman2001>
at least for me
<ankurgel>
:D
<andkerosine>
You're taking an ugly approach.
<andkerosine>
ankurgel: I think the problem becomes a /whole/ lot clearer if you extract out the anagram checking.
<ankurgel>
extract out? as in separate function?
<andkerosine>
Mm-hmm.
<andkerosine>
Have a method that returns whether or not two strings are anagrams, and then another which does the combining by taking each word, grabbing its anagrams from the remaining list, and then popping them out of the list so that they don't get processed again.
<ankurgel>
I can declare function within a function, right?
<andkerosine>
You don't want [['racs', 'scar']] and [['scar', 'racs']]
<ankurgel>
and call internal function, outside.
<andkerosine>
Yes, but don't. : )
<andkerosine>
It's never good practice, really.
<andkerosine>
If you ask the question because it strikes you as a good idea to keep related functions together, bravo, but do it as a class or module.
tyman has joined #ruby-lang
<ankurgel>
hm, I have to keep it in a single function, function is provided with list of words, it returns back OUTPUT
postmodern has joined #ruby-lang
<andkerosine>
That is, you are only given access to the internal structure of the combine_anagrams method?
<ankurgel>
yes.
<andkerosine>
Ah.
jkyle has joined #ruby-lang
<ankurgel>
have to submit this one actually. They only require this function to judge.
<andkerosine>
Mm-hmm.
chessguy has joined #ruby-lang
<andkerosine>
#select is /the/ function to use here.
<dominikh>
*method
<injekt>
method method method
<andkerosine>
Got me.
<injekt>
psh
<dominikh>
injekt: hah!
<injekt>
dammit dominikh
<ankurgel>
haha
* andkerosine
seppuku.
<injekt>
of all people
<injekt>
fml
<ankurgel>
but, select will only select a group at a time, no?
<andkerosine>
That's what you want.
<andkerosine>
You want to go through each word in the lest, select its anagrams from the rest, and then go to the next.
<andkerosine>
*list
<ankurgel>
group can be framed for other anagram cases too.
<ankurgel>
yeah
<andkerosine>
Right, #select inside of an iteration.
<ankurgel>
but, again, that select will provide me with that sorted array matching result.
<ankurgel>
I have to show the original words from list.
<ankurgel>
or probably I can use array addressing to address that array instead.
<injekt>
what are you doing? the backtrace is impossible to read
Bwild has joined #ruby-lang
<ankurgel>
injekt, me?
<andkerosine>
It must take in an array of words and return them grouped as anagrams, no?
<injekt>
ankurgel: sure
<ankurgel>
andkerosine, yes. whatever strings are anagram, group'em.
rushed has joined #ruby-lang
<andkerosine>
Mm-hmm. Then iterating over the word list, #select-ing the anagrams, and pushing them into the return array is the solution.
<ankurgel>
injekt, yeah, my bad, I messed that sentence
<andkerosine>
ankurgel: My solution uses #each, #select, #split, #sort, and #uniq. : )
<dreinull>
is there something like tconsole for any app, not just rails?
<ankurgel>
andkerosine, with that kickass guidance of you. It's all what is present on my vi: https://gist.github.com/1968795
<ankurgel>
s/you/yours*
<andkerosine>
That... didn't work?
<ankurgel>
see the output in that gist.
<ankurgel>
I need to pair original elements: [["cars", "racs", "scar"], ["four"], ["for"],["potatoes"], ["creams", "scream"]]
<andkerosine>
Yes.
<andkerosine>
word_copy isn't getting used.
<ankurgel>
exactly
<andkerosine>
That is your enemy.
<ankurgel>
but, it was needed to save that somewhere, no?
<andkerosine>
Not at all.
<ankurgel>
Then, how do I get original elements back?
<andkerosine>
Rather, use the original, and instead do your anagram check /inside/ the #select.
<ankurgel>
unless I'm creating hash out of them.
<ankurgel>
probably
<andkerosine>
No need for a hash.
<ankurgel>
hm
<ankurgel>
ok
<ankurgel>
I can include an iterator within an iterator?
<ankurgel>
in blocks*
<andkerosine>
Bam!
<ankurgel>
^Affirmation? :)
<andkerosine>
Oh, yes.
<andkerosine>
'Tis the secret.
<andkerosine>
No need for results /and/ arr, though.
<ankurgel>
AND NOW I SHALT HAZ IT
<ankurgel>
:)
<andkerosine>
Also, #downcase and #join are superfluous.
<ankurgel>
join is to bring back those tiny little pieces back..
<andkerosine>
['a', 'c', 't'] == ['a', 'c', 't'], so no sense in joining them.
<ankurgel>
so that they can be checked against for anagrams..
<ankurgel>
oh
<ankurgel>
compare of them will give true?
<andkerosine>
Mm-hmm.
<ankurgel>
cool
<andkerosine>
Ruby doesn't have to know they're words, really.
<andkerosine>
Just that they're made of the same pieces.
<ankurgel>
after using #select, one word from original_array is pushed in,
<ankurgel>
I'm now supposed to use an iterator within taht,
<ankurgel>
which will check for anagram.
<ankurgel>
Legit?
<andkerosine>
Not quite.
<andkerosine>
#select is where pretty much everything should happen.
<ankurgel>
MIND==SCREWED :D
<andkerosine>
The recipe: prepare empty results array, iterate over each word and #select everything that is an anagram of that word (including the word itself, which should make things a bit easier), push the results of that #select into the array.
<andkerosine>
The array will then contain duplicates wherever an anagram was found, so return the array with duplicates removed.
<injekt>
my face hurts when I look at this channel
<ankurgel>
injekt, he was faster than irb, so, well.. :D
<ankurgel>
s/was/is
<injekt>
nothing is faster than irb
<dominikh>
pry is
<injekt>
tololol stfu
<dominikh>
tololol? what are you, asian?
<injekt>
possibly
<ankurgel>
hm.. not quite.
Weems has joined #ruby-lang
Weems has joined #ruby-lang
<injekt>
anyone got an r i can borrow?
<dominikh>
ask the pirates
<injekt>
har
<andkerosine>
ankurgel: No, but if you sort the initial word list before you iterate, then all of the anagram arrays will be in order, which means #uniq will remove them properly.
<andkerosine>
Well, no, a sort really isn't necessary. You're iterating over the word list in the same order each time, so the anagram arrays that get pushed will always be in the same order.
<ankurgel>
overkill. It's almost morning here. Lost sleep session :O
<ankurgel>
fuzzy fuzzy fuzzy
<injekt>
soo many words, soo little code
<ankurgel>
yes, but I learnt/is_learning a lot, that matters. :)
<andkerosine>
I support that notion.
<andkerosine>
Still, it's homework, feels indecent to provide a complete solution.
<ankurgel>
definitely, I'll have to do it myself.
kain has joined #ruby-lang
<ankurgel>
atleast, pretentiously :P
<andkerosine>
Mm-hmm.
<ankurgel>
already got help in every line, so can't say that I'm making it myself.
<andkerosine>
Try to have it going in your conscious mind as you fall asleep.
<andkerosine>
Sort of hard to do intentionally, but it's glorious when it happens.
<shevy>
lol
<andkerosine>
I love waking up and remembering what code I was thinking about.
<ankurgel>
hahaha
<shevy>
cool
<shevy>
code tends to make me angry
<ankurgel>
this one was interesting. I had one or two incidents, when I slept giving up on some program,
<injekt>
shevy: that's good
<ankurgel>
and after waking up it automatically striked!
<andkerosine>
It is a wondrous experience.
<andkerosine>
shevy: Builds character... or something.
<shevy>
yeah good for workout, I use this energy to keep fit and punch things in my surroundings
burns180 has joined #ruby-lang
<erikh>
disregard irc, acquire commits
<injekt>
translate: disregard irc, WRITE SOME FUCKING CODE
<manveru>
andkerosine: also, there already exist around 4 implementations of that in the stdlib
<Spooner>
When I've used that sort of write-to-disk config, I've exposed self[a, b, ...]= on the wrapper, so that you aren't going through hashes directly.
wallerdev has joined #ruby-lang
<manveru>
there is YAML::Store, SDBM, GDBM, DBM
<manveru>
also PStore
<andkerosine>
I'm going for minimal dependencies.
<andkerosine>
I want it to be dead-simple for people to use.
<manveru>
it's fuckin stdlib, how minimal can you get?
<Spooner>
stdlib is about as minimal as it can be.
<andkerosine>
Oh...
<dominikh>
if you want minimal maybe you should use perl, I heard it's installed by default on most systems!
<manveru>
sorry, i'm tired ^^;
<manveru>
anw, the *DBM ones are really recommended, since they don't have to rewrite the whole data every time it changes
<manveru>
YAML::Store is just a wrapper for PStore, which uses Marshal by default
<manveru>
but since everyone and their dog are in love with mongoriakcachedcouchdb they get no love :(
<andkerosine>
Yajl's fast. : )
<manveru>
not if you have to write the whole thing every time
<manveru>
HDD is slow
<Spooner>
Depends. If it is a 10-line config file, I doubt it matters.