<Seenox>
Hello. What is the best way to read a json file line by line and convert datas into hashes of hashes?
<ljarvis>
Seenox: File.each_line
Silthias has joined #ruby
JeanCarloMachado has quit [Remote host closed the connection]
<ljarvis>
then split the line into words (if that's what you want), String#split
<Seenox>
ljarvis: Thanks, going to read it now.
<ljarvis>
then hash them (this changes based on what algo you want)
<ljarvis>
oh sorry json file
Sou|cutter has quit [Ping timeout: 240 seconds]
<ljarvis>
the json file contains arrays or something?
<Seenox>
ljarvis: Yes, I will show you an example in a minute.
<ljarvis>
ok, in which case you probably want JSON.parse once you've read the file (you could use a streamed parser if the file is huge and you wanted to avoid excess memory)
<allisio>
Seenox: Your JSON is slightly ill-formed; you're missing the closing brackets on the internal hashes, and the trailing commas are considered syntax errors by the standard library's JSON module.
<Seenox>
Burgestrand: Thanks! Exactly what I needed. What if I've another nested_hash inside a nested_hash for example? Should I break it again with .each?
<Burgestrand>
Seenox if you provide an example of what your data contains, and what you'd like to get out, I might be able to help you with the translation stuff inbetween :)
patarr has quit [Ping timeout: 240 seconds]
<Seenox>
Burgestrand: Sure. One moment please.
<Burgestrand>
Seenox typically `each` is only useful when you want to iterate through the data and do some side effect (usually printing), methods such as `select`, `map`, `filter`, etc are useful when you want to modify the data in some way and keep the result to continue working with it
<Burgestrand>
Seenox that said, a side effect in `each` could be a variable outside the loop that you also modify, usually there's a more pure (side effect-free) way of doing it, which may or may not be nicer :)
<Seenox>
Burgestrand: It will be 5000 hashes inside a hash.
Cohedrin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Burgestrand>
Seenox with some kind of key, so in fact it's more like `host_hash = { "some key" => { "ID" => 37, … }, "some other key" => { "ID" => 48, … } }`?
JeanCarloMachado has quit [Ping timeout: 258 seconds]
<Seenox>
Burgestrand: Should I avoid each and use select and map in this example? I want to remove all hashes which doesn't contain a certain value from a specific key.
JeanCarloMachado has joined #ruby
<Seenox>
Burgestrand: No they don't have that first key.
<Burgestrand>
Seenox every hash has a key and a value
<Burgestrand>
Seenox if those two hashes you provided are in a hash, then they have a key
<Seenox>
Burgestrand: When I use host_hash.each do |each_host|, then it returns each block of those hashes.
<Seenox>
Burgestrand: Which looks like what I've sent you as example of my hash.
<Burgestrand>
Seenox can you show the result of `host_hash.class`
<Seenox>
Burgestrand: Hmm, I am lost I think. should I do 'puts host_hash.class' ?
<Burgestrand>
Seenox yes :)
<Seenox>
Burgestrand: Array
<Burgestrand>
Seenox hehe, figures, so your `host_hash` is not a hash, it's an array, which is a list of hashes, and not a hash of hashes, it doesn't change too much but it's an important distinction
<Seenox>
Burgestrand: Exactly. They should be converted into list of hashes first?
<Burgestrand>
Seenox not at all! But I'd probably name the variable something like `hosts_array` or even just `hosts`
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<Burgestrand>
Seenox an example code to keep only the hosts with an `operatingsystem_name` matching the text `Debian` anywhere could look like this: `debians = host_array.keep_if { |host| /Debian/ === host.dig("Betriebssystem", "operatingsystem_name") }`
depesz has joined #ruby
depesz has left #ruby [#ruby]
<Burgestrand>
Seenox e.g. an example that filters on environment: https://eval.in/785344
d10n-work has quit [Quit: Connection closed for inactivity]
jackrandom has quit [Remote host closed the connection]
Ar_Da has joined #ruby
<Ar_Da>
hi
<Ar_Da>
How can I extract a substring from another string taking N character after and before the substring. For instance I have a string like this: aaaabbbccccctttoooo. I want to extract "cccc" and 4 character after and before so I get abbbcccctttto
<Ar_Da>
sorry It would be abbbccccttto
jsrn_ has joined #ruby
<Burgestrand>
Ar_Da What if you don't have either 4 characters before and/or after?
<Ar_Da>
Burgestrand: that's a nice point
<Ar_Da>
my problem is that I dunno any delimiter
<Ar_Da>
so I think I have to something more complex to check that you say
<Burgestrand>
Ar_Da that'll allow 0 to 4 characters before and after, might be a bit finnicky with newlines
<Seenox>
Burgestrand: Did I do something terribly wrong?
<Burgestrand>
Seenox did it work terribly?
tvw has joined #ruby
<Seenox>
Burgestrand: No, but I got an error.
<Burgestrand>
Seenox ooh, exciting, what error?
<Ar_Da>
Burgestrand: thank you
<Burgestrand>
Ar_Da yw :)
<Seenox>
Burgestrand: `block in <main>': undefined method `dig' for #<Hash:0x00000001c03770> (NoMethodError) from test.rb:12:in `keep_if' from test.rb:12:in `<main>'
<Burgestrand>
Seenox ah, I betcha you're on an older version of ruby than the one I'm used to
JeanCarloMachado has quit [Ping timeout: 264 seconds]
<Burgestrand>
Seenox you can replace `host.dig("hostgroup_name")` with just `host["hostgroup_name"]`
<Seenox>
Burgestrand: I am on 1.9.1
mogaj has joined #ruby
lxsameer has joined #ruby
<Burgestrand>
Seenox aye, it's way old and not even receiving security patches these days, but it's not uncommon to have it as the system ruby still because… well… systems lag behind
JeanCarloMachado has joined #ruby
roamingdog has quit [Ping timeout: 240 seconds]
<Seenox>
Burgestrand: Worked. but just returned [].
mogaj has quit [Client Quit]
<Seenox>
Burgestrand: as in my example, I want to keep each of hashes (or Array?) that contains that Debian in hostgroup_name in it.
<Burgestrand>
Seenox ah, yes, you'll need `host["Betriebssystem"]["hostgroup_name"]`, since the `hostgroup_name` is nested inside another hash inside the host
<Burgestrand>
Seenox downside to using `[]` instead of `dig` here is that you'll get an error if the key "Betriebssystem" is missing from any host, but with some luck your data is fairly uniform :)
<Seenox>
Burgestrand: Awesome! It worked.
<Burgestrand>
Seenox \o/
<Seenox>
Burgestrand: [6, 16, 48, 50]
<Burgestrand>
Seenox if the value is surrounded by `[…]` then it's an Array, if it's surrounded by `{…}` it's a hash
<Seenox>
Burgestrand: So it will be ok to work with them for further data editing in it as arrays?
<Burgestrand>
Seenox yeah it's no problem, the thing is you need to know what format your data is in
roamingdog has quit [Remote host closed the connection]
mim1k_ has joined #ruby
cdg has joined #ruby
roamingdog has joined #ruby
workmad3 has joined #ruby
jameser has quit [Client Quit]
sonOfRa has quit [Quit: Bye!]
mim1k_ has quit [Read error: Connection reset by peer]
gaucheph has joined #ruby
bernd27 has quit [Ping timeout: 260 seconds]
sonOfRa has joined #ruby
mjuszczak has joined #ruby
mjuszczak has quit [Max SendQ exceeded]
mjuszczak has joined #ruby
jrafanie has joined #ruby
workmad3_ has joined #ruby
workmad3 has quit [Ping timeout: 240 seconds]
jameser has joined #ruby
workmad3 has joined #ruby
millerti has joined #ruby
patr0clus has joined #ruby
jameser has quit [Read error: Connection reset by peer]
dcunit3d has joined #ruby
workmad3_ has quit [Ping timeout: 255 seconds]
millerti has quit [Read error: Connection reset by peer]
Snowy has joined #ruby
mniip has joined #ruby
DLSteve has joined #ruby
scrooloose has joined #ruby
beauby has joined #ruby
djbkd_ has joined #ruby
gottcha has joined #ruby
djbkd_ has quit [Ping timeout: 240 seconds]
mim1k has joined #ruby
haylon has joined #ruby
jameser has joined #ruby
timvisher has joined #ruby
dcunit3d has quit [Ping timeout: 240 seconds]
jameser has quit [Ping timeout: 240 seconds]
Snowy has quit [Quit: ragequit]
mtkd has quit [Ping timeout: 260 seconds]
mtkd has joined #ruby
nobodyzxc has joined #ruby
mooser has quit [Remote host closed the connection]
valentinul has joined #ruby
Beams has quit [Remote host closed the connection]
Beams has joined #ruby
vali has quit [Ping timeout: 258 seconds]
valentinul has quit [Ping timeout: 276 seconds]
mim1k has quit [Ping timeout: 258 seconds]
ldnunes has quit [Ping timeout: 260 seconds]
rkazak has joined #ruby
Guest96 has quit [Remote host closed the connection]
GodFather__ has quit [Ping timeout: 240 seconds]
blackmes1 has quit [Ping timeout: 240 seconds]
patarr has joined #ruby
patarr_ has joined #ruby
skade_ has joined #ruby
Guest96 has joined #ruby
jaruga has joined #ruby
daf__ has quit [Ping timeout: 260 seconds]
jaruga has quit [Remote host closed the connection]
mooser has joined #ruby
jaruga has joined #ruby
beauby has quit [Ping timeout: 240 seconds]
ResidentBiscuit has joined #ruby
mim1k has joined #ruby
__Yiota has joined #ruby
kobain has joined #ruby
User458764 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
blackmes1 has joined #ruby
workmad3 has quit [Ping timeout: 255 seconds]
GodFather__ has joined #ruby
whiteline has quit [Read error: Connection reset by peer]
User458764 has joined #ruby
whiteline has joined #ruby
theunraveler has joined #ruby
whiteline has quit [Max SendQ exceeded]
BSAlb has joined #ruby
whiteline has joined #ruby
mikecmpb_ has joined #ruby
theunraveler has quit [Client Quit]
theunraveler has joined #ruby
BSaboia has quit [Ping timeout: 240 seconds]
mikecmpbll has quit [Ping timeout: 240 seconds]
fusta has joined #ruby
last_staff has quit [Quit: last_staff]
gizmore has quit [Ping timeout: 276 seconds]
gizmore has joined #ruby
mark_66 has quit [Read error: Connection reset by peer]
mark_66 has joined #ruby
BSab has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
nopacien13 has joined #ruby
SuperLag has joined #ruby
jimeh has quit [Ping timeout: 264 seconds]
cardoni has quit [Ping timeout: 264 seconds]
Pongles has quit [Ping timeout: 264 seconds]
dionysus69 has quit [Remote host closed the connection]
nahra has quit [Remote host closed the connection]
justinmrkva has quit [Ping timeout: 255 seconds]
tsunamie has quit [Ping timeout: 240 seconds]
andersh has quit [Ping timeout: 255 seconds]
ewilliam__ has quit [Ping timeout: 255 seconds]
dionysus69 has joined #ruby
nahra has joined #ruby
bcavileer has quit [Ping timeout: 264 seconds]
avdi has quit [Ping timeout: 264 seconds]
mrsolo has quit [Ping timeout: 264 seconds]
johnkpaul has quit [Ping timeout: 264 seconds]
kireevco has quit [Ping timeout: 264 seconds]
troter__________ has quit [Ping timeout: 264 seconds]
pfg has quit [Ping timeout: 264 seconds]
bove has quit [Ping timeout: 264 seconds]
solidsnack has quit [Ping timeout: 264 seconds]
Heero__ has quit [Ping timeout: 255 seconds]
headius has quit [Ping timeout: 240 seconds]
roamingd_ has joined #ruby
Jello_Raptor has quit [Ping timeout: 240 seconds]
davic has quit [Ping timeout: 276 seconds]
kiltzman has quit [Ping timeout: 260 seconds]
jaruga has quit [Remote host closed the connection]
abort_ has quit [Ping timeout: 255 seconds]
planigan has quit [Ping timeout: 240 seconds]
tatey has quit [Ping timeout: 240 seconds]
mitsuhiko has quit [Ping timeout: 264 seconds]
jcp___ has quit [Ping timeout: 264 seconds]
nopacienc3 has quit [Ping timeout: 264 seconds]
jaruga has joined #ruby
mrbobbytables has quit [Ping timeout: 276 seconds]
dukedave has quit [Ping timeout: 276 seconds]
Guest10418 has quit [Ping timeout: 255 seconds]
szulak has quit [Quit: bye!]
davic has joined #ruby
jimcroft has quit [Ping timeout: 255 seconds]
oliv_____ has joined #ruby
oliv_____ has quit [Client Quit]
boshhead has quit [Ping timeout: 240 seconds]
balazs has quit [Ping timeout: 240 seconds]
guacamole has quit [Ping timeout: 240 seconds]
TheMoonMaster has quit [Ping timeout: 264 seconds]
charles81_ has quit [Ping timeout: 264 seconds]
chromis has quit [Ping timeout: 264 seconds]
noodle has quit [Ping timeout: 264 seconds]
ec\_ has quit [Ping timeout: 264 seconds]
edwardly has quit [Ping timeout: 264 seconds]
t-richards has quit [Ping timeout: 264 seconds]
Gnubie_ has quit [Ping timeout: 255 seconds]
justinmcp has quit [Ping timeout: 255 seconds]
BSAlb has quit [Ping timeout: 255 seconds]
Liothen has quit [Ping timeout: 255 seconds]
jdelstrother has quit [Ping timeout: 255 seconds]
rjungemann has quit [Ping timeout: 255 seconds]
justinmcp has joined #ruby
chef3000 has quit [Ping timeout: 260 seconds]
iamayam has quit [Ping timeout: 276 seconds]
ytti_ has quit [Ping timeout: 258 seconds]
Gnubie_ has joined #ruby
MrBloo has quit [Ping timeout: 264 seconds]
vcoinminer has quit [Ping timeout: 264 seconds]
skmp has quit [Ping timeout: 264 seconds]
ahuman has quit [Ping timeout: 264 seconds]
pmarreck has quit [Ping timeout: 264 seconds]
tomphp has joined #ruby
boshhead has joined #ruby
hotpancakes has joined #ruby
seggy has quit [Ping timeout: 240 seconds]
CrazyEddy has quit [Ping timeout: 276 seconds]
jpinnix has quit [Ping timeout: 276 seconds]
roamingdog has quit [Ping timeout: 255 seconds]
moufl has quit [Ping timeout: 246 seconds]
ytti has joined #ruby
ahuman has joined #ruby
pupsicle1 has joined #ruby
guidos has quit [Ping timeout: 264 seconds]
sent-hil has quit [Ping timeout: 240 seconds]
allisio has quit [Ping timeout: 240 seconds]
Majost has quit [Ping timeout: 255 seconds]
kies has quit [Ping timeout: 255 seconds]
joevandyk has quit [Ping timeout: 255 seconds]
abort has joined #ruby
jmhmccr has quit [Ping timeout: 276 seconds]
ec\ has joined #ruby
jimcroft has joined #ruby
iamayam has joined #ruby
greenhat has quit [Ping timeout: 264 seconds]
brixen has quit [Ping timeout: 264 seconds]
freeze has quit [Ping timeout: 264 seconds]
vondruch has quit [Client Quit]
csk_ has quit [Ping timeout: 255 seconds]
Tharbakim has quit [Ping timeout: 240 seconds]
daed has quit [Ping timeout: 255 seconds]
noodle has joined #ruby
daed has joined #ruby
vondruch has joined #ruby
duckpupp1 has quit [Ping timeout: 276 seconds]
darthvorik has quit [Ping timeout: 240 seconds]
chrisarcand has quit [Ping timeout: 255 seconds]
Pongles has joined #ruby
jcp___ has joined #ruby
kies has joined #ruby
TheMoonMaster has joined #ruby
pupsicle has quit [Ping timeout: 264 seconds]
pupsicle1 is now known as pupsicle
jpinnix has joined #ruby
mattp__ has quit [Ping timeout: 240 seconds]
CrazyEddy has joined #ruby
mrbobbytables has joined #ruby
chrisarcand has joined #ruby
manveru has quit [Ping timeout: 264 seconds]
vcoinminer has joined #ruby
spiette has quit [Ping timeout: 255 seconds]
csk has joined #ruby
jmhmccr has joined #ruby
kireevco has joined #ruby
kiltzman has joined #ruby
greenhat has joined #ruby
dukedave has joined #ruby
MrBloo has joined #ruby
Majost has joined #ruby
<hxegon>
Lavan: Hey! Is the cursor not going all the way up to the cell value because the ciphertext isn't that long? Otherwise it would be an out of bounds, right?
last_staff has joined #ruby
Liothen has joined #ruby
patarr has quit [Ping timeout: 260 seconds]
moufl has joined #ruby
rwb has joined #ruby
solidsnack has joined #ruby
MissionCritical has quit [Ping timeout: 255 seconds]
duckpupp1 has joined #ruby
edwardly has joined #ruby
edwardly has joined #ruby
edwardly has quit [Changing host]
mitsuhiko has joined #ruby
justinmrkva has joined #ruby
tatey has joined #ruby
fumk has quit [Ping timeout: 264 seconds]
Jello_Raptor has joined #ruby
mattp__ has joined #ruby
bove has joined #ruby
mrsolo has joined #ruby
rjungemann has joined #ruby
brixen has joined #ruby
skade_ has quit [Ping timeout: 260 seconds]
Heero__ has joined #ruby
t-richards has joined #ruby
pmarreck has joined #ruby
conta has quit [Ping timeout: 276 seconds]
allisio has joined #ruby
gaucheph has quit [Ping timeout: 276 seconds]
planigan has joined #ruby
patarr has joined #ruby
balazs has joined #ruby
andersh has joined #ruby
tsunamie has joined #ruby
Tharbakim has joined #ruby
Tharbakim has joined #ruby
Tharbakim has quit [Changing host]
darthvorik has joined #ruby
szulak has joined #ruby
spiette has joined #ruby
fumk has joined #ruby
hogetaro_ has joined #ruby
cardoni has joined #ruby
hogetaro has quit [Ping timeout: 268 seconds]
antgel has quit [Ping timeout: 260 seconds]
avdi has joined #ruby
workmad3 has joined #ruby
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
guacamole has joined #ruby
<Lavan>
ive just noticed that it does goall the way up so it is not the problem
<al2o3-cr>
Lavan: is this some sort of challenge?
johnkpaul has joined #ruby
gheegh has joined #ruby
mooser has quit [Remote host closed the connection]
chromis has joined #ruby
bcavileer has joined #ruby
conta1 has joined #ruby
charles81_ has joined #ruby
tomphp has joined #ruby
mooser has joined #ruby
pfg has joined #ruby
skmp has joined #ruby
mooser has quit [Remote host closed the connection]
centrx has joined #ruby
jimeh has joined #ruby
apparition has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mooser has joined #ruby
ewilliam__ has joined #ruby
manveru has joined #ruby
headius has joined #ruby
jdelstrother has joined #ruby
jdelstrother is now known as Guest51193
<Lavan>
yes it is
<centrx>
It begins
<Lavan>
it is a challenge al2o3-cr
mooser has quit [Remote host closed the connection]
last_staff has quit [Quit: last_staff]
antgel has joined #ruby
rippa has joined #ruby
mooser has joined #ruby
Sou|cutter has joined #ruby
mikecmpb_ has quit [Quit: inabit. zz.]
patarr has quit [Quit: leaving]
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
patarr_ has quit [Quit: leaving]
mooser has quit [Remote host closed the connection]
<al2o3-cr>
i can't see why that last part is malformed
Burgestrand has quit [Quit: Closing time!]
mim1k has quit [Ping timeout: 276 seconds]
patarr_ has joined #ruby
cfec0b8d has quit [Remote host closed the connection]
patarr has quit [Ping timeout: 260 seconds]
aufi has quit [Ping timeout: 276 seconds]
MissionCritical has joined #ruby
theunraveler has quit []
theunraveler has joined #ruby
theunraveler has quit [Client Quit]
theunraveler has joined #ruby
polishdub has joined #ruby
theunraveler has quit [Client Quit]
cahoots has quit [Ping timeout: 268 seconds]
<Lavan>
how did you make it to work al2o3-cr??!
cpruitt has joined #ruby
<Lavan>
its awesome
<Lavan>
what happend there really? can you explain the solution al2o3-cr ? what did you do there with the [c%128].pack('C') and is it the only difference
ferr has quit [Quit: WeeChat 1.7]
tercenya has quit [Remote host closed the connection]
tercenya has joined #ruby
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<al2o3-cr>
Lavan: it's the same as (c%128).chr i was just checking something before oh, and dir = 1 if cursor < 0 instead of <= the rest you earned :P
patarr_ has quit [Ping timeout: 240 seconds]
<Lavan>
alright this is so cool
<Lavan>
now i really wonder why there's still a lil bit of cipher left scrambled...
<al2o3-cr>
it's still not right though
<Lavan>
no no, it turns out to be right...
<al2o3-cr>
i'll have another look after got to go
<Lavan>
almost right at least, but you can figure the password from that
brent__ has joined #ruby
roamingd_ has quit [Read error: Connection reset by peer]
<Lavan>
thanks alot :D
workmad3_ has joined #ruby
roamingdog has joined #ruby
roamingdog has quit [Remote host closed the connection]
roamingdog has joined #ruby
brent__ has quit [Remote host closed the connection]
roamingdog has quit [Remote host closed the connection]
brent__ has joined #ruby
roamingdog has joined #ruby
roamingdog has quit [Remote host closed the connection]
mim1k has joined #ruby
roamingdog has joined #ruby
roamingdog has quit [Remote host closed the connection]
conta1 has quit [Ping timeout: 258 seconds]
roamingdog has joined #ruby
workmad3 has quit [Ping timeout: 264 seconds]
ledestin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
roamingdog has quit [Remote host closed the connection]
roamingdog has joined #ruby
roamingdog has quit [Remote host closed the connection]
patr0clus has quit [Read error: Connection reset by peer]
workmad3 has joined #ruby
xpitr is now known as ecdsa521
patr0clus has joined #ruby
<centrx>
FYI Ruby is the best programming language
workmad3_ has quit [Ping timeout: 255 seconds]
cahoots has joined #ruby
<ytti>
glad that's settled now
<ytti>
i'd love to review the paper
<ytti>
i have some additional questions and concerns
sonOfRa has quit [Remote host closed the connection]
BSaboia has joined #ruby
sonOfRa has joined #ruby
joevandyk has joined #ruby
BSAlb has joined #ruby
duderonomy has quit [Ping timeout: 268 seconds]
BSab has quit [Ping timeout: 260 seconds]
cahoots has quit [Quit: leaving]
BSaboia has quit [Ping timeout: 276 seconds]
blackmes1 has joined #ruby
Yxhuvud has quit [Read error: Connection reset by peer]
rkazak has quit [Quit: Sleep.....ing....]
Yxhuvud has joined #ruby
<kspencer>
is there a library where I can run var.parent.arbitrary.child = value, without dealing with the 'no method' and that can be returned as a hash
amclain has joined #ruby
<ljarvis>
kspencer: well, that's not a hash, they're method calls
seggy has joined #ruby
<ljarvis>
unless you mean foo[:bar][:baz][:child] = value
chopin has joined #ruby
<ljarvis>
also, srsly law of demeter
rkazak has joined #ruby
cagomez has joined #ruby
cagomez has quit [Remote host closed the connection]
mark_66 has quit [Remote host closed the connection]
cagomez has joined #ruby
cagomez has quit [Read error: Connection reset by peer]
cagomez has joined #ruby
hotpancakes has quit [Remote host closed the connection]
<ruby[bot]>
chef3000: pastebin.com loads slowly for most, has ads which are distracting and has terrible formatting.
<elomatreb>
chef3000: It was not, and neither was any question
Frites has quit [Ping timeout: 240 seconds]
<chef3000>
I am attempting to delete all files in a folder except for one. The gist is my attempt. Wondering if there is a better/preferred way to achieve this. Thanks.
<kspencer>
Even without looking at that, looping through the directories files and doing an if in there to see if its the one you want sounds like the easiest route to me
tlaxkit has joined #ruby
<elomatreb>
FileUtils.rm takes a list (an array) of files, so you could use array difference
vasilakisfil has quit [Quit: Konversation terminated!]
<ccooke>
that could be quite bad if the set of files is big, though
<elomatreb>
The list of files or the list of exceptions?
<ccooke>
The set of files
<chef3000>
It will actually be run against a yum repo directory, so the files in that folder will be very few.
marxarelli|afk is now known as marxarelli
<chef3000>
thank you that is what I was looking for.
gusrub has joined #ruby
txjoe_ has joined #ruby
tlaxkit has quit [Quit: tlaxkit]
txjoe_ has left #ruby [#ruby]
User458764 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
GodFather__ has quit [Ping timeout: 240 seconds]
nobodyzxc has quit [Quit: leaving]
skade_ has joined #ruby
jaruga has quit [Quit: jaruga]
outreachdan has joined #ruby
Beams has quit [Quit: .]
mim1k has quit [Ping timeout: 264 seconds]
mikecmpbll has quit [Quit: inabit. zz.]
mtkd has quit [Ping timeout: 246 seconds]
aspiers has joined #ruby
skade_ has quit [Ping timeout: 276 seconds]
mtkd has joined #ruby
BSab has joined #ruby
Cohedrin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
JeanCarloMachado has quit [Ping timeout: 240 seconds]
LastWhisper____ has joined #ruby
<LastWhisper____>
hey guys
<havenwood>
LastWhisper____: hi
BSaboia has joined #ruby
LastWhisper____ has left #ruby [#ruby]
LastWhisper____ has joined #ruby
BSAlb has quit [Ping timeout: 264 seconds]
<LastWhisper____>
hey havenwood
chef3000 has quit [Quit: Page closed]
JeanCarloMachado has joined #ruby
<LastWhisper____>
I'm writing a small blog post and trying to come up with some ruby snippets that represent "Guitar output" digitally
<LastWhisper____>
so each string is represented similar to [1,2,3,4,5]
<LastWhisper____>
and if you were to iteratively strum each one, the output would be like [1,2,3,4,5], but with a "delay" effect, it would be [1,1,2,2,3,3,4,4,5,5] (this part is easy)
BSab has quit [Ping timeout: 240 seconds]
workmad3_ has joined #ruby
<LastWhisper____>
the next level though, is to represent "feedback" which would look a bit like this [1,1,1,1,1,1,2,2,2,1,1,2,1,2,1,2,1,2,1,2,1]
ben______ has joined #ruby
<LastWhisper____>
from what i'm told, feedback is feeding the delay signal back into itself
workmad3 has quit [Ping timeout: 255 seconds]
<LastWhisper____>
I'm trying to think of a way to represent that just playing around with arrays though and I can't think of any besides just doing some manual work and concatenating
roamingdog has joined #ruby
brent__ has quit [Remote host closed the connection]
ben_____ has quit [Ping timeout: 255 seconds]
troter__________ has joined #ruby
raspado has joined #ruby
jrafanie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
guidos has joined #ruby
jrafanie has joined #ruby
sent-hil has joined #ruby
beauby has joined #ruby
<canton7>
maybe the sticking point is that audio isn't just "one note then another" - they're added together
roamingdog has quit [Ping timeout: 276 seconds]
pupsicle has quit [Remote host closed the connection]
hotpancakes has quit [Remote host closed the connection]
pupsicle has joined #ruby
brent__ has joined #ruby
ColeHub has joined #ruby
hotpancakes has joined #ruby
__Yiota has quit [Remote host closed the connection]
AndBobsYourUncle has quit [Ping timeout: 276 seconds]
rprimus has joined #ruby
jackrandom has joined #ruby
nitric has joined #ruby
kies has quit [Ping timeout: 258 seconds]
mooser has quit [Ping timeout: 255 seconds]
cdg has joined #ruby
ColeHub has quit [Ping timeout: 240 seconds]
kent\n has quit [Quit: No Ping reply in 180 seconds.]
centrx has quit [Remote host closed the connection]
kent\n has joined #ruby
gheegh has joined #ruby
jrafanie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Guest96 has quit [Remote host closed the connection]
hotpancakes has quit [Remote host closed the connection]
rakm has joined #ruby
hotpancakes has joined #ruby
Guest96 has joined #ruby
tristanp_ has quit []
bigkevmcd has quit [Quit: Outta here...]
quobo has joined #ruby
hotpanca_ has joined #ruby
tristanp has joined #ruby
hotpancakes has quit [Read error: Connection reset by peer]
skade_ has joined #ruby
justizin has joined #ruby
JeanCarloMachado has quit [Remote host closed the connection]
gusrub has quit [Remote host closed the connection]
ldnunes has joined #ruby
JeanCarloMachado has joined #ruby
tercenya has quit [Remote host closed the connection]
tercenya has joined #ruby
patr0clus has quit [Read error: Connection reset by peer]
milardovich has joined #ruby
rkazak has quit [Quit: Sleep.....ing....]
ColeHub has joined #ruby
blackmesa has quit [Ping timeout: 240 seconds]
patr0clus has joined #ruby
kristofferR has quit [Remote host closed the connection]
kies has joined #ruby
agent_white has quit [Quit: agent_white]
blackmesa has joined #ruby
Cohedrin has joined #ruby
rkazak has joined #ruby
flying has quit []
User458764 has joined #ruby
cout has joined #ruby
MrBusiness has joined #ruby
perniciouscaffei has joined #ruby
<cout>
I have a short script that calls out to another program (let's say with system()) and I want to pass the exit status back unmodified. If I use exit $?.to_i, then that fails for the false command ($?.to_i is 256 so the effective exit code is 0). If I use exit $?.exitstatus then that fails for a program that aborts and dumps core ($?.to_i is 134 but $?.exitstatus is nil since the program terminated abnormally).
petruff has quit [Ping timeout: 240 seconds]
<cout>
I'm tempted to write exit($?.exitstatus || $?.to_i), but I'm not confident that's right either
mikecmpbll has joined #ruby
Cohedrin has quit [Max SendQ exceeded]
petruff has joined #ruby
nhhc has joined #ruby
bernd27 has joined #ruby
Cohedrin has joined #ruby
hotpanca_ has quit [Remote host closed the connection]
hotpancakes has joined #ruby
jackrandom has quit [Ping timeout: 264 seconds]
<eam>
cout: you want $?.exitstatus
unshadow has quit [Quit: leaving]
<eam>
the exit status on unix is a 16 bit integer, and the value returned by exit() is 8 bit
<eam>
the other 8 bits are filled in by the kernel
<eam>
$?.exitstatus are those 8 bits relevant to exit()
hotpancakes has quit [Remote host closed the connection]
aupadhye has quit [Ping timeout: 240 seconds]
* dminuoso
slaps eam for linking outdated documentation
hotpancakes has joined #ruby
* dminuoso
pokes eam with his eskrima sticks
<toretore>
im still running 1.9
<cout>
eam: but if the child terminates abnormally, exitstatus is nil, and exit(nil) isn't valid since nil is not an integer
<eam>
abnormally how?
<cout>
int main() { abort(); }
hotpancakes has quit [Ping timeout: 255 seconds]
BSAlb has joined #ruby
hotpancakes has joined #ruby
romank has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
patarr has joined #ruby
workmad3_ has quit [Ping timeout: 276 seconds]
<eam>
seems like a bug
<eam>
all processes have an exit code
<cout>
man 2 wait
<toretore>
shouldn't you be checking `exited?` explicitly?
romank has joined #ruby
<cout>
WEXITSTATUS() has no meaning unless the child terminated normally
akkad has joined #ruby
<eam>
cout: well, otherwise it's zero
<cout>
toretore: exitstatus does that for you
<cout>
eam: I think it's undefined in that case (so maybe 0, maybe something else)
<toretore>
i mean as a matter of being explicit in itself
<toretore>
if exited? then exitstatus else something_weird_happened end
<eam>
WEXITSTATUS is 7 bits right?
<cout>
I could probably argue it both ways
BSaboia has quit [Ping timeout: 240 seconds]
nobitanobi has quit [Remote host closed the connection]
<cout>
eam: seems to be 8 bits; not sure if that's guaranteed
<eam>
or is that just shell convention?
<toretore>
if you come back in a year and see `exitstatus || to_i` you'll probably not understand what it means
nobitanobi has joined #ruby
<sunrunner20>
new to ruby
<sunrunner20>
just found a script that has an integer with an underscore in it: 86_400
<cout>
toretore: I think to_i is probably wrong but I don't know why
skweek has joined #ruby
<cout>
toretore: so I'm using exitstatus || 127 for now
<toretore>
sunrunner20: it is ignored
<apeiros>
sunrunner20: underscores in integers are ignored
<sunrunner20>
k
<sunrunner20>
so its just there to pretend to be a thousands indicator
t-recx has quit [Quit: t-recx]
<apeiros>
s/to pretend/
<eam>
shell convetion is to set the 8th bit if something went wrong and exit(3) wasn't called
romank has quit [Ping timeout: 246 seconds]
<eam>
and to push that other 8 bites of data down into the exit code
<toretore>
cout: yeah i don't know what the right status to return is, i'm just arguing that the abnormal case should be explicit and obvious
<eam>
seems like you'd want to adopt a similar mechanism if you want to do the same
mooser has joined #ruby
<eam>
the problem is you're wanting to return the full 16 bits (whether abort was called, etc) but only using the last 8 bits
<eam>
so /bin/sh does that by reserving the high bit and mapping the behaviors in
sonOfRa has quit [Quit: Bye!]
<cout>
eam: I'm wanting to stick to convention
nobitanobi has quit [Ping timeout: 276 seconds]
chouhoulis has quit [Remote host closed the connection]
skweek has quit [Ping timeout: 246 seconds]
petruff1 has joined #ruby
<cout>
eam: or rather, I'm wanting to stick to _correct_ convention (convention in ruby seems to be to blindly use exitstatus, which for reasons mentioned above is wrong)
duderonomy has joined #ruby
mostlybadfly has joined #ruby
mjuszcza_ has joined #ruby
workmad3 has joined #ruby
sonOfRa has joined #ruby
psychicist__ has joined #ruby
mooser has quit [Ping timeout: 246 seconds]
mjuszczak has quit [Ping timeout: 260 seconds]
petruff has quit [Ping timeout: 276 seconds]
cdg_ has joined #ruby
cdg has quit [Ping timeout: 276 seconds]
<Lavan>
al2o3-cr , might you have a suggestion on attacking the next problem? now there's another ciphered text without a key, but they do tell you that the key consists of 3 descriptors, and the final result includes only english letters, spaces, and '?' '.'
Oclair has joined #ruby
Jody has joined #ruby
workmad3 has quit [Ping timeout: 264 seconds]
<Lavan>
what i think you should do is brute force through all 3 descripors combination, stopping when you don't get any character that don't fall to the criteria (english letters, spaces,'?','.')
petruff1 has quit [Ping timeout: 246 seconds]
<Lavan>
or maybe someone else has an idea
<Lavan>
guys, a question for you all...
<hxegon>
Lavan that sounds like you'd get a lot of false positives, but I can't think of a better soluion off the top of my head
<Lavan>
suppose you have an array like this [[0,0,0],[0,0,0],[0,0,0]].you want to change it each iteration so it iterates through all combinations from [[0,0,0],[0,0,0],[0,0,0]] to [[255,255,255],[255,255,255],[255,255,255]]
<Lavan>
I'm thinking of a way to implement it... i don't think it'll give us too many false positive as it would seem at glance... just a feeling. the problem is i can't be confident enough on the correctness of the former code.
freeze has joined #ruby
<Lavan>
because it got the result with minor errors that would make the whole expression wrong in such test
<hxegon>
is the key just three sub-arrays?
<Lavan>
yes, the key is just three sub arrays
patarr has quit [Ping timeout: 240 seconds]
Yxhuvud has quit [Read error: Connection reset by peer]
faces has quit [Ping timeout: 260 seconds]
Yxhuvud has joined #ruby
mondongo has joined #ruby
<hxegon>
Lavan: hold on
patarr has joined #ruby
mondongo has left #ruby [#ruby]
GinoMan has quit [Ping timeout: 245 seconds]
synstack has quit [Changing host]
synstack has joined #ruby
cdg_ has quit [Remote host closed the connection]
<Lavan>
ok no problem
patr0clus has quit [Quit: WeeChat 1.4]
enterprisey has joined #ruby
Oclair has quit [Quit: Bye Bye]
rakm has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
chopin has quit [Remote host closed the connection]
rakm has joined #ruby
preyalone has joined #ruby
Bock has quit [Read error: Connection reset by peer]
rakm has quit [Client Quit]
rakm has joined #ruby
rakm has quit [Client Quit]
chopin has joined #ruby
rakm has joined #ruby
rakm has quit [Client Quit]
jusa has joined #ruby
rakm has joined #ruby
skade_ has quit [Ping timeout: 240 seconds]
rakm has quit [Client Quit]
rakm has joined #ruby
rakm has quit [Client Quit]
skade_ has joined #ruby
GinoMan has joined #ruby
vuoto has joined #ruby
patarr has quit [Ping timeout: 240 seconds]
AndrewIsHere has joined #ruby
hotpancakes has quit [Remote host closed the connection]
hotpancakes has joined #ruby
patarr has joined #ruby
fusta has quit [Quit: Leaving]
hotpanca_ has joined #ruby
hotpancakes has quit [Read error: Connection reset by peer]
nhhc has quit [Remote host closed the connection]
jrafanie has joined #ruby
cfec0b8d has joined #ruby
workmad3 has joined #ruby
roamingdog has joined #ruby
chouhoulis has joined #ruby
tercenya has quit [Remote host closed the connection]
faces has joined #ruby
tercenya has joined #ruby
vuoto has quit [Remote host closed the connection]
<hxegon>
Lavan: ok, so the brute force might take a while, considering it's worst case 256 ^ 9 * how long it takes to check if a key 'works' for the ciphertext
<Lavan>
any other leads?
<Lavan>
you are right...
<hxegon>
No other leads though. Do you have the problem statement?
mjuszcza_ has quit [Read error: Connection reset by peer]
<hxegon>
I have an easyish way to make subkey permutations though, so theres that
<LastWhisper____>
i ended up leaving the feedback effect out of it I felt it was a bit of an overcomplication
tercenya has quit [Remote host closed the connection]
tercenya has joined #ruby
centrx has joined #ruby
centrx has joined #ruby
centrx has quit [Changing host]
ColeHub has quit [Quit: Snooze.]
Jody_ has joined #ruby
GodFather__ has joined #ruby
Jody_ is now known as Jody
<hxegon>
LastWhisper____: I'll read this when I get a minute. I've been thinking about getting an OP-1 to try and get into music production, so this is right up my alley :)
roamingdog has joined #ruby
<LastWhisper____>
sweet! the post is very ... basic i don't go into a lot of detail music production wise, it's just the main design pattern of software development & music production that follow similar patterns
<Lavan>
this permutation trick, i have a problem with it.. each time if i set foo to what you wrote, and i set key to be key=[foo,foo,foo] then i need if i .next all/each/only one of the foos, i dont get all of the overall posiible permutations
<hxegon>
.next is only supposed to get one possible permutation
<hxegon>
if you try using foo.next to get 3 subkeys you won't cover the entire keyspace
skweek has joined #ruby
<Lavan>
i want to apply each time 3 subkeys...
GinoMan has joined #ruby
<Lavan>
and i want to apply all 3 subkeys combinations
<hxegon>
you couldn't, for example, get [[0, 0, 0], [0, 0, 0], [0, 0, 0]] as a possible key this way
<hxegon>
you could do something like define 3 of those enumerators and take permutations from each one for each of the 3 subkeys, but this doesn't cover everything either
<Lavan>
it doesn't bother me.... [0,0,0],[0,0,0],[0,0,0] just won't do anything
<hxegon>
bad example, a better one would be [[1, 2, 3], [1, 2, 3], [1, 2, 3]], which would be a valid possible subkey
<hxegon>
valid possible key*
<Lavan>
it is a valid key, what is the problem with it?
Xakotu has joined #ruby
ldnunes_ has joined #ruby
<hxegon>
the problem is you can't get it by going [foo.next, foo.next, foo.next] because you'd get 3 permutations of a subkey space. It would have to be 3 different possible subkeys.
ldnunes has quit [Read error: Connection reset by peer]
<Lavan>
yes, exactly, that's the problem i had with understanding your trick - it doesn't help me cover all "upper" permutations...
Jody has quit [Ping timeout: 260 seconds]
<hxegon>
you could probably change my snippet to cover all possible permutations of keys rather than just subkeys somehow
<Lavan>
i need all permutations from [0,0,0],[0,0,0],[0,0,0] to [255,255,255],[255,255,255],[255,255,255]
cschneid_ has joined #ruby
patarr has quit [Ping timeout: 240 seconds]
<Lavan>
at least that what i think i need
gchristensen has left #ruby ["WeeChat 0.4.2"]
hotpancakes has joined #ruby
skade_ has quit [Ping timeout: 260 seconds]
<hxegon>
there's definitely a way to do that with #permutation, but I can't quite get the right invocation in pry
<ika_>
havenwood I am generaly new to open source contributions has alwayse worked in a commercial companies. So is it possible to work on weekends like on part time and still give needed progress?
<al2o3-cr>
Lavan: as i see it, is, as before with op, code, len but bruteforce
u0_a170 has quit [Ping timeout: 240 seconds]
<havenwood>
ika_: Yes. There are a wide variety of Ruby gems that are great for contributing to. Documentation for gems or Ruby-proper is a good way to start. Contributing to Ruby itself is a bit rockier than the path to contribute to most gems, but it's doable.
<havenwood>
ika_: Or there are countless other gems.
<Lavan>
each triplet is a step. in the problem statement they say the key is consisted of 3 steps... if i just brute force as before, as far as i understand what you mean, i get a chain of more than 3 steps
<al2o3-cr>
ah, maybe you're right
<ika_>
havenwood generaly what I mean is that if you take a task is there a deadline. Or I can work it on free time without hurry
<Lavan>
a step is : first byte- opcode, second byte- param, third byte -length
<al2o3-cr>
Lavan: have you got the encrypted message, i'll play around.
<havenwood>
ika_: It totally depends. There are plenty of things that aren't in a rush that you should have no want.
<Lavan>
yes i have got it
<Lavan>
but...
<Lavan>
i wanna like be able to understand the solution
<Lavan>
just a sec
ColeHub has joined #ruby
<havenwood>
ika_: Sporadic contribution is still much appreciated.
<al2o3-cr>
Lavan: if i figure it out, i'll talk you though my methodolgy
Cohedrin has quit [Read error: Connection reset by peer]
u0_a170 has quit [Ping timeout: 240 seconds]
Cohedrin has joined #ruby
milardovich has quit [Remote host closed the connection]
cagomez has joined #ruby
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
__Yiota has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
milardovich has joined #ruby
<patarr>
`derpy: awesome thanks! Do you by any chance also know of anything like chunk, given an input of truthy and falsy values, will only chunk the truthy ones? Aka, if I had truthy, truthy, truthy, falsy - that would be two chunks. But if I had falsy, falsy, truthy, truth - that would be 4 chunks [[falsy],[falsy],[truthy,truthy]]
centrx has quit [Remote host closed the connection]
jamesaxl has quit [Remote host closed the connection]
chopin has quit []
gusrub has joined #ruby
roamingdog has quit [Remote host closed the connection]
xco has left #ruby [#ruby]
cagomez has quit [Ping timeout: 264 seconds]
bernd27 has quit [Ping timeout: 260 seconds]
<elomatreb>
patarr: You likely mean apeiros, `derpy is a bot
biberu has quit []
milardovich has quit [Remote host closed the connection]
cyberRodent has quit [Ping timeout: 240 seconds]
milardovich has joined #ruby
bernd27 has joined #ruby
<patarr>
lol yes I meant that towards apeiros
jrafanie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
milardovich has quit [Ping timeout: 240 seconds]
__Yiota has joined #ruby
BSaboia has quit [Ping timeout: 240 seconds]
jamesaxl has joined #ruby
dionysus69 has quit [Ping timeout: 255 seconds]
__Yiota has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]