<yorickpeterse>
perhaps I finally can move things over to Sequel
marcofernandez has joined #ruby-lang
* yorickpeterse
dreams of unicorns and pixies
<Eising>
<3 sequel
<ruby-lang786>
let's say the input is cd "c:\exam ple", can regex do just read what's inside the quotes ?
<oddmunds>
yes
<apeiros_>
yorickpeterse: since I'm implementing my own enum thingy - what parts are bad about AR's?
<yorickpeterse>
apeiros_: it maps to an integer column in the database, removing the possibility for the DB to optimize queries for the exact possible values
<yorickpeterse>
e.g. say you have an enum of X and Y
<yorickpeterse>
(so ENUM(X, Y))
pr0ton has quit [Ping timeout: 272 seconds]
mbr has quit [Read error: Connection reset by peer]
<yorickpeterse>
In that case the DB would know that at any given point _only_ X or Y could be used
<yorickpeterse>
with an integer that could be any 64bit integer value
<yorickpeterse>
It's also much more strict: you force validation to occur in the DB
<yorickpeterse>
So you can't bypass AR models and insert some random crap value in the column
<yorickpeterse>
In this particular case I have a column that denotes polarity of a word, which can be: positive or negative
<yorickpeterse>
oh and "neutral"
sirpeng has quit [K-Lined]
workmad3 is now known as wm3|away
some-person has joined #ruby-lang
<yorickpeterse>
_if_ Pg optimizes for this I'm not sure yet, but even then the strictness is still a big plus over using a random integral value
loveablelobster has left #ruby-lang ["Textual IRC Client: www.textualapp.com"]
yfeldblum has joined #ruby-lang
<apeiros_>
are you sure there's actually performance to be gained over a 64bit int? given that that's usually the fastest thing on current CPUs?
<yorickpeterse>
Also, when using AR's method I suspect the integer values are set based on the order in the enum
<yorickpeterse>
so if you ever re-sort it you're fucked
<ruby-lang786>
One last question, can you make it support space too. I'll just do gsub("cd ","") and rest of space the regex should handle and if it's not a valid dir I'll just depend on the users smartness
Stichoza has joined #ruby-lang
<apeiros_>
I mean you could save space. but you can do that by specifying the size of the number. NUMBER(2,0) in sql so?
<yorickpeterse>
apeiros_: Storage size is a non issue
<apeiros_>
ok. I doubt you can gain performance with a different datatype.
<yorickpeterse>
The minimum size of an int is 8 bytes on Pg, but it will store that for every row
<yorickpeterse>
whereas with an enum I believe, I could be wrong, it's simply a pointer
<yorickpeterse>
At least if it doesn't actually use a pointer to the enum value it's fucking dumb
<apeiros_>
the sort order - yepp. I see that requiring an update of all records. which is painful. but I'm not sure whether there are better alternatives.
mbr has joined #ruby-lang
<apeiros_>
the ones that come to my mind either use a join (slow) or a function to lookup the order value of a enum value (slow too)
<yorickpeterse>
apeiros_: by not relying on numeric (or other generated) values the sort order problem doesn't exist
<yorickpeterse>
Since enums are named it doesn't matter in what order they are defined in the schema
yfeldblum has quit [Ping timeout: 252 seconds]
skade has joined #ruby-lang
<apeiros_>
oh, you don't mean "sort records by enum value"
<apeiros_>
you mean "generate integer from enum value, based on its index in the enum"
Sadin has joined #ruby-lang
scampbell has joined #ruby-lang
<yorickpeterse>
What I mean is this:
<yorickpeterse>
enum :letters, [:a, :b, :c]
<yorickpeterse>
Here :a would probably be 1, :b 2, :c 3, etc
<yorickpeterse>
but if somebody ever decides "yo lets resort that" it might suddenly be :a => 2, :b => 1, :c => 3
<yorickpeterse>
Then your whole DB is screwed
<apeiros_>
yes
<apeiros_>
you'd either need an explicit mapping, or must not touch the order
<yorickpeterse>
Of course you could add "# DO NOT EVER RESORT THIS ARRAY" but it's bound to happen
<Sadin>
morning all
<apeiros_>
so AR does not save the enum to the db… that's something I do differently
<yorickpeterse>
Correct, it does it all in Ruby
simi has quit [Ping timeout: 265 seconds]
<apeiros_>
my approach is using an int too. but I a) provide pg functions to convert strings to int etc., and b) store the enum in the db.
<yorickpeterse>
Honestly I'm starting to believe more and more that ActiveRecord is an ORM with crutches and training wheels
<apeiros_>
all ORMs are
<yorickpeterse>
one with a slight mental disability too
pr0ton has joined #ruby-lang
<yorickpeterse>
apeiros_: Sequel is pretty darn good, though it's not really an ORM in the traditional sense
<apeiros_>
IMO & IME you can't have ORM + DBI without leaky abstraction
<yorickpeterse>
That is, it's more of a DB toolkit that happens to have an ORM built-in
<apeiros_>
I think you can't even have just DBI without being leaky.
<apeiros_>
(one of the reasons why I decided to go pg-only with my thing)
<Eising>
yorickpeterse: Sequel can be very ORM-like, and it can also not be, which is quite wonderful
<yorickpeterse>
Eising: exactly
<some-person>
Hello. I'm learning ruby and i cannot understand dup method in "The Ruby Programming Language" book. http://pastebin.com/LiPmjzcb
<ljarvis>
what is it with pastebin
<yorickpeterse>
But ugh, moving over everything from AR to Sequel is quite the challenge
<apeiros_>
I think I've never used sequel's ORM
<yorickpeterse>
something I'm not going to do now
<yorickpeterse>
some-person: dup copies the object
<ljarvis>
some-person: super calls the same method on the superclass
<apeiros_>
some-person: you usually should not define dup/clone yourself
<yorickpeterse>
basically I'll, hopefully, be ranting about Ruby :P
malconis has quit [Remote host closed the connection]
<maloik>
not mongo?
<maloik>
pssh
AmirolAhmad has quit []
yxhuvud has joined #ruby-lang
<yorickpeterse>
Part of Mongo won't exist anymore by then for us
<yorickpeterse>
If all goes well that is
<yorickpeterse>
I hope to have one cluster shut down by that time, with another one remaining
<yorickpeterse>
That last one will be a PITA since the app stores data in ways that can't be stored easily in SQL
<yorickpeterse>
Unless I abuse Pg's json storage system, which is stupid
<apeiros_>
some-person: that dup implementation is bad. really. but what it does:
<yorickpeterse>
Argh ffs, I'll just use AR 4.1 enums
<apeiros_>
it calls `dup` from the superclass which returns a copy of self. that copy is stored in copy.
<apeiros_>
it then replaces its own @grid with a copy of @grid, so that copy and self have different objects for @grid
<apeiros_>
and in the last line it returns the copy
<apeiros_>
this is bad because: a) you should not define dup, you should define initialize_copy.
<apeiros_>
b) .dup should absolutely NOT modify self. this dup implementation does.
malconis has joined #ruby-lang
<apeiros_>
the reason for a) is that #initialize_copy is used for both, #dup and #clone. this implementation simply "forgets" about clone. and now this class' #clone is broken.
<some-person>
apeiros_: I'm just trying to understand the code from book :)
<apeiros_>
some-person: yes. I understood that. that's why I gave you a line by line explanation.
chussenot has joined #ruby-lang
<apeiros_>
and additionally I told you why that book's implementation is bad. so you can do better.
marcofernandez has quit [Ping timeout: 265 seconds]
shinnya has joined #ruby-lang
ruby-lang786 has quit [Ping timeout: 246 seconds]
<some-person>
apeiros_: Thank you for your explanation but i don't understand one thing: "it then replaces its own @grid with a copy of @grid" How does interpreter recognize that @grid it isn't @grid of "self", but it is @grid of "copy" and @grid.dup is @grid of "self" rather than @grid of "copy"?
<apeiros_>
some-person: no, you misunderstand. @grid is indeed self's @grid
<some-person>
apeiros_: @grid = @grid.dup looks like self.grid = self.grid.dup for me
<apeiros_>
some-person: it replaces self's @grid with a copy of self's @grid
<apeiros_>
which is precisely why it is a bad implementation - it modifies self.
<darix>
some-person: variables are just references to objects
<darix>
so the object references by @grid will be the copy
<darix>
you can see that by comparing the object IDs e.g.
<apeiros_>
i.e., instead of creating a copy with a copy of @grid, it creates a copy with self's @grid and then - to separate the two - replaces its own @grid with a copy
arBmind has joined #ruby-lang
<apeiros_>
some-person: to exemplify: you have Puzzle A with grid A. you call .dup on it. `copy = super` creates Puzzle B, whose @grid still has grid A. now `@grid = @grid.dup` replaces Puzzle A's grid with grid B. so you end up with Puzzle A having @grid B, and Puzzle B having @grid A.
ta has quit [Remote host closed the connection]
malconis has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<apeiros_>
but normally you'd want to end up with Puzzle A keeping its @grid A, and Puzzle B having its own @grid B.
marcofernandez has joined #ruby-lang
chills42 has quit [Ping timeout: 256 seconds]
<some-person>
apeiros_: It returns a copy of itself without changes but replaces its own grid by a new grid. Have i understood it rightly?
* yorickpeterse
is looking for a sane max size for VARCHAR
* yorickpeterse
doesn't really care since this will be using TEXT in Pg in a little while anyway
<ljarvis>
use text in pg?
<ljarvis>
ehh
<yorickpeterse>
:P
<yorickpeterse>
Yeah this is only because herp derp MySQL can't index TEXT unless you give a max index size
marcofernandez has quit [Ping timeout: 272 seconds]
<ljarvis>
I'd say 45 then
araujo has joined #ruby-lang
araujo has quit [Changing host]
araujo has joined #ruby-lang
AKASkip has quit [Ping timeout: 264 seconds]
chills42 has joined #ruby-lang
<yorickpeterse>
I'll just go with the default 255 :P
chinmay_dd has joined #ruby-lang
<apeiros_>
some-person: correct
<apeiros_>
some-person: a better way to do it would be: `def initialize_copy; @grid = @grid.dup; end`. Ruby calls initialize_copy on the copy after dup/clone.
charliesome has quit [Quit: zzz]
marcofernandez has joined #ruby-lang
tlr has joined #ruby-lang
<apeiros_>
this would result in dup returning a copy of Puzzle which also has a copy of grid
<some-person>
apeiros_: Thank you for your explanation.
yfeldblum has joined #ruby-lang
deryl has joined #ruby-lang
<deryl>
Anyone know of a fairly well fleshed out ruby Dev env for android? Wondering if I can do a little bit of coding while I'm waiting for the new laptop.
<deryl>
Something that does not require to root your device. (Like for grabbing a pty or something)
yfeldblum has quit [Ping timeout: 255 seconds]
benlovell has quit [Ping timeout: 264 seconds]
jkad1 has joined #ruby-lang
pr0ton has quit [Quit: pr0ton]
<whitequark>
android is not a posix platform
<whitequark>
don't expect posix software to run on it
<whitequark>
that being said, there's ruboto.
jgpawletko has joined #ruby-lang
<deryl>
Hmm. Heard of ruboto but don't know much about it. Will expend some google time on it. Thanks whitequark
<maloik>
rubymotion supports android
wm3|away_ has joined #ruby-lang
<deryl>
And for the POSIX info. Didn't know that
elastik has joined #ruby-lang
<whitequark>
maloik: not for development ON android
marcofernandez has quit [Ping timeout: 264 seconds]
<maloik>
oh my bad, misread
<deryl>
Isn't rubymotion payware? Just looking for something free for about a week
<deryl>
Ah ok
<maloik>
I'd look at webbased environments
chills42_ has joined #ruby-lang
<maloik>
I know there's a few out there, can't seem to remember the names though
chills42 has quit [Read error: Connection reset by peer]
<deryl>
There was one that I saw out there that supported ruby in the web browser but I cannot for the life of me remember its name
<deryl>
Yeah me either
<deryl>
Codetree or something like that. Something else to google
<darix>
deryl: ruboto?
<darix>
or mirah or so
wm3|away has quit [Ping timeout: 244 seconds]
<maloik>
though isn't ruboto basically the same as rubymotion?
<maloik>
I thought it was :o
<deryl>
Cool. Couple things to look up. Appreciate the pointers.
<yorickpeterse>
Vim runs on android
<darix>
mirah.org
<yorickpeterse>
Though you have to use some Android port of it
<yorickpeterse>
I wonder if Emacs could fit on it :D
jkad1 has quit [Quit: WeeChat 1.0.1]
<deryl>
16gb galaxy s5 active. It should hehe
<deryl>
Darix mirah.org appears DNS dead
st0mar has joined #ruby-lang
marcofernandez has joined #ruby-lang
<yorickpeterse>
deryl: Not sure if that would leave enough resources to run an editor
* yorickpeterse
runs
enebo has joined #ruby-lang
* deryl
chuckles
marcofernandez has quit [Remote host closed the connection]
mattyohe has joined #ruby-lang
<deryl>
Yorick that actually might not be too far from the truth. I have a 2gb processor and 2gb of RAM in this bonnie. I've found a couple of things that I've had insufficient memory to run. I have a feeling I might be able to add Emacs to that. Lol
arBmind has quit [Read error: Connection reset by peer]
<deryl>
s/bonnie/phone/
<yorickpeterse>
:P
st0mar has quit [Ping timeout: 265 seconds]
ruby-lang333 has quit [Ping timeout: 246 seconds]
frank_o has joined #ruby-lang
Guest49231 is now known as samkottler
samkottler has quit [Changing host]
samkottler has joined #ruby-lang
clauswitt has quit [Ping timeout: 252 seconds]
skade has quit [Read error: Connection reset by peer]
Artemitch has joined #ruby-lang
j2p2 has quit []
chouhoulis has joined #ruby-lang
chouhoulis has quit [Remote host closed the connection]
klmlfl has quit [Remote host closed the connection]
skade has joined #ruby-lang
matsutomo has joined #ruby-lang
senor_jalapeno has joined #ruby-lang
benlovell has joined #ruby-lang
klmlfl has joined #ruby-lang
st0mar has joined #ruby-lang
jkad1 has joined #ruby-lang
momomomomo has joined #ruby-lang
momomomomo has quit [Client Quit]
jimbach has joined #ruby-lang
ta has joined #ruby-lang
ta has quit [Remote host closed the connection]
ta has joined #ruby-lang
elastik has quit [Ping timeout: 264 seconds]
yfeldblum has joined #ruby-lang
nathanstitt has joined #ruby-lang
shambrarian has joined #ruby-lang
whippythellama has joined #ruby-lang
snoopybbt has joined #ruby-lang
oleo has joined #ruby-lang
nofxx has joined #ruby-lang
Shazaum has joined #ruby-lang
Shazaum has quit [Changing host]
chills42_ has quit [Ping timeout: 240 seconds]
yfeldblum has quit [Ping timeout: 245 seconds]
<deryl>
whitequark ruboto installed. Looks like it'll do what I need. Thanks
<deryl>
Core and irb in place
chills42 has joined #ruby-lang
cmhobbs has joined #ruby-lang
jkad1 has quit [Quit: WeeChat 1.0.1]
momomomomo has joined #ruby-lang
ta has quit [Remote host closed the connection]
ta has joined #ruby-lang
matsutomo has quit [Quit: matsutomo]
nathanstitt has quit [Quit: Laters]
kiyote23 has joined #ruby-lang
matsutomo has joined #ruby-lang
momomomomo has quit [Ping timeout: 272 seconds]
chills42 has quit [Remote host closed the connection]
nathanstitt has joined #ruby-lang
elastik has joined #ruby-lang
pr0ton has joined #ruby-lang
<Sadin>
if i create a gemfile and ran bundle install, how do i get my ruby program to see it when i run the rb file. The method that should be available is not because it doesnt know the library is there
koderok has joined #ruby-lang
<jhass>
start with bundle exec or make require 'bundler/setup' the first require
Xzanron has quit [Read error: Connection reset by peer]
whippythellama has quit [Quit: whippythellama]
<Sadin>
jhass: i include, require 'bundler/setup' in my main rb file?
<jhass>
I usually have no such thing, but yes
<jhass>
if you're not writing a gem that is
chinmay_dd has quit [Quit: Leaving]
<Sadin>
jhass: no im trying to use a gem
whippythellama has joined #ruby-lang
<jhass>
one's not excluding the other ;)
loincloth has joined #ruby-lang
koderok has quit [Remote host closed the connection]
<nofxx_>
mr_r_j_p, you should post the code of that method (paste)
<darix>
the very first sentence on the page ;)
<nofxx_>
Just for fun, but why YAML parses "08:07:06: bbone" -> {29226=>"bbone"}
<mr_r_j_p>
ok thanks I didn't see that
<mr_r_j_p>
It's not so much a concern bu t just curious
<darix>
nofxx_: seconds since mid night
<darix>
wild guess
<nofxx_>
I know it's wrong, just expeculating.... was expecting maybe { 8 => { 7 => { 6...
AKASkip has joined #ruby-lang
pikos has quit [Remote host closed the connection]
<darix>
nofxx_: not without the newlines i think
yfeldblum has joined #ruby-lang
<darix>
8*3600+7*60+6
<darix>
=> 29226
<nofxx_>
darix, wow... hh:mm:ss ?
<darix>
looks like it
kiyote23 has joined #ruby-lang
clauswitt has joined #ruby-lang
clauswitt has quit [Client Quit]
<nofxx_>
haha crazy... yeah, with invalid date/time values it goes back to string -> "08:07:99:55:03"
<darix>
to get your expected output you would need
<darix>
YAML.load("08:\n 07:\n 06: bbone")
<nofxx_>
actually I expect the string, it's mac address (or part of it)
<nofxx_>
it's actually device: xx:xx:xx ... was playing with the mac adress as key just to see waht happens
<darix>
YAML.load("'08:07:06': bbone")
<nofxx_>
yeah, quote it
<darix>
glad we could solve that
<nofxx_>
darix, thanks! force to symbol works too!
<nofxx_>
:08:07:06
yfeldblum has quit [Ping timeout: 258 seconds]
<darix>
well
<darix>
question is
<darix>
if you have {"08:07:06"=>"bbone"}
<darix>
to_yaml should output it quoted
<darix>
(and it does for me)
<darix>
so how did the unquoted string end up in your yaml file?:)
kiyote23 has quit [Ping timeout: 244 seconds]
<nofxx_>
was just experimenting with colons on the key
<darix>
ok
centrx has joined #ruby-lang
djbkd has joined #ruby-lang
maek has joined #ruby-lang
st0mar has quit [Ping timeout: 264 seconds]
thatsnotjack has quit [Quit: leaving]
Guest29 has joined #ruby-lang
allomov has quit [Remote host closed the connection]
<maek>
Im writing a chef recipe but I think this is a ruby question. doing a Base64.decode64 on a variable before assigning to another variable should work right? knife_client_key = Base64.decode64(node[:merlin][:knife_client_key]) it seems to just pass the still base64 encoded string
djbkd has quit [Quit: My people need me...]
[H]unt3r has quit [Remote host closed the connection]
[H]unt3r has joined #ruby-lang
klmlfl has joined #ruby-lang
marr has quit [Ping timeout: 252 seconds]
<darix>
works for me
<maek>
darix: can you show me what you did. Im not so good at ruby in general.
<maek>
darix: also, thanks!
<wallerdev>
make sure you use the variable knife_client_key
<maek>
wallerdev: I am for sure
<wallerdev>
:)
<maek>
:)
Artemitch has joined #ruby-lang
<wallerdev>
maybe the string is base64 encoded twice
<wallerdev>
maybe just try printing out the value after decode64
<wallerdev>
and before
<darix>
maek: you can also try: node[:merlin][:knife_client_key] = Base64.decode64(node[:merlin][:knife_client_key])
<darix>
just in case some other code bypasses your own variable and directly accesses the node structure
[H]unt3r has joined #ruby-lang
GBrawl has quit [Ping timeout: 272 seconds]
klmlfl has quit [Ping timeout: 264 seconds]
<maek>
darix, thanks!
<maek>
let me poke
x-light has joined #ruby-lang
<maek>
I have instances of base64.decode working with out the require in chef, fwiw.
<darix>
maek: it just means something else loaded the library before your code is running
<maek>
yeah, was just saying I think chef auto loads that
<maek>
as ive never needed to require. a side comment :D
nofxx_ has quit [Ping timeout: 260 seconds]
<wallerdev>
chef probably already requires it somewhere
<wallerdev>
ugh i cleaned my desk this morning and already spilled some coffee on it haha
<maek>
thats why you shouldnt clean.
<maek>
I had never split any liquid on my desk and last week I got a sweet new keyboard, of course 10 min after setting it up, spill coffee all over it :|
<yorickpeterse>
that's why you shouldn't drink near your desk
<centrx>
that's why you should be drunk near your desk
<yorickpeterse>
or learn not to spill your shit
<centrx>
*shouldn't
nofxx_ has joined #ruby-lang
nofxx_ has joined #ruby-lang
chinmay_dd has quit [Read error: Connection reset by peer]
yourabi has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
klmlfl has joined #ruby-lang
cleopatra has joined #ruby-lang
<wallerdev>
haha i spilled my coffee walking over to my desk with it, so I set it on some paper towel but it leaked through a bit
<wallerdev>
nothin major
_JokerDoom has joined #ruby-lang
momomomomo has joined #ruby-lang
imperator has joined #ruby-lang
JokerDoom has quit [Ping timeout: 244 seconds]
rbowlby has joined #ruby-lang
loincloth has joined #ruby-lang
pikos has joined #ruby-lang
eristic_ is now known as eristic
senor_jalapeno has joined #ruby-lang
deryl has joined #ruby-lang
ur5us has joined #ruby-lang
bmichelsen has joined #ruby-lang
Stichoza has quit [Quit: Be back later ...]
pikos has quit [Remote host closed the connection]
yfeldblum has joined #ruby-lang
_fritchie has joined #ruby-lang
[H]unt3r has quit [Remote host closed the connection]
[H]unt3r_ has joined #ruby-lang
Stichoza has joined #ruby-lang
marr has joined #ruby-lang
Guest29 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
_fritchie has quit [Read error: Connection reset by peer]
_fritchie has joined #ruby-lang
imperator has quit [Quit: Valete!]
ldnunes has quit [Quit: Leaving]
stichoza_ has joined #ruby-lang
javajax has joined #ruby-lang
Stichoza has quit [Ping timeout: 258 seconds]
cleopatra has quit [Remote host closed the connection]
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
shazaum_ has quit [Quit: This computer has gone to sleep]
sirpeng has joined #ruby-lang
mr_r_j_p has quit [Quit: Page closed]
stichoza_ has quit [Read error: Connection reset by peer]
stichoza_ has joined #ruby-lang
stichoza_ has quit [Read error: Connection reset by peer]
stichoza_ has joined #ruby-lang
stichoza_ has quit [Read error: Connection reset by peer]
stichoza_ has joined #ruby-lang
kiyote23 has joined #ruby-lang
stichoza_ has quit [Read error: Connection reset by peer]