The web in a box - a next generation web framework for the Perl programming language

IRC log for #mojo, 2015-06-02

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:00 damaya_ I'm just generating a string like 4a9zzka2a, which is fine with me, but without another column in the database, doing it from the surrogate key
00:00 damaya_ based on this: https://github.com/inscitiv/pg_random_id
00:01 damaya_ I'm not so concerned about the friendly_id part, just a unique identifier that does not require I check to see if it is unique before inserting.
00:03 Grinnz you have to check if it's unique before inserting, or you will get errors eventually
00:03 Grinnz it's just a question of how long
00:05 damaya_ Well, this pg_random_id creates the random id from the surrogate key, so no extra column to store data, no worrying about it being unique.
00:05 damaya_ I don't know, maybe it's not a good solution?
00:05 Grinnz you need to be able to look up the row by this ID as well, does this do that?
00:06 damaya_ no :/
00:06 damaya_ just realized that
00:06 damaya_ haha
00:06 damaya_ I was using PostgreSQL's uuid_version_4, but it's way too long and looks ugly.
00:07 damaya_ Oh well, I'm just going to create a column and store a random string. Wrap it while loop until what's wrapped in try succeeds.
00:07 damaya_ bleh
00:09 damaya_ seems ugly, but I don't think it's too bad; better than the alternatives I guess.
00:09 damaya_ now, time for some pizza
00:09 damaya_ remember when you used to compile your kernel and it'd tell you to go make a pizza, take a nap, come back tomorrow?
00:09 damaya_ haha
00:09 damaya_ Thanks Grinnz :)
00:13 mattastrophe joined #mojo
00:27 davido__ joined #mojo
00:35 zivester joined #mojo
00:46 punter joined #mojo
01:01 csson joined #mojo
01:04 bpmedley damaya: Have you seen: https://metacpan.org/pod/Data::UUID
01:07 preaction Data::UUID would give you a uuid4. also, who cares how long an ID is, it's an ID
01:08 bpmedley I must have misunderstood the conversation.
01:10 preaction [18:46:58]  <damaya_>I was using PostgreSQL's uuid_version_4, but it's way too long and looks ugly.
01:10 bpmedley Doh
01:10 preaction a bit for that reason i've been back into auto-increment IDs lately
01:11 preaction i won't use auto-increments when sharding, or when trying interoperability, but for simple databases it works fine
01:30 zivester joined #mojo
01:34 damaya_ foo.com/p/uuidv4 is ugly
01:34 damaya_ or, at least imo it is
01:35 Grinnz_ yeah, it's a consideration you have to make when using ids in urls
01:36 damaya_ well, I'm not so against foo.com/p/<6charstring>, but uuidv4 is a bit much
01:36 damaya_ regardless, at the moment it doesn't really matter, this is what I do constantly when developing, get caught up in the details and never finish :D
01:36 Grinnz_ the other option is the SEO option: take a "title" of some kind and convert it into a url-friendly unique "tag" :P
01:37 Grinnz_ but that's usually just an optional section after a unique identifier in the URL anyway
01:37 damaya_ yeah, I was going to do /p/<rand_string>/the_title_here
01:37 klapperl joined #mojo
01:37 Grinnz_ thats what a lot of sites do
01:37 Grinnz_ like reddit
01:37 damaya_ not that I really care about Google, or any other search engine for that matter
01:38 damaya_ Ah yeah, Reddit does that
01:38 damaya_ Considering what I am making is so similar to Reddit, I might as well imitate that too
01:38 damaya_ haha
01:39 Grinnz_ the url-friendly conversion usually consists of dropping any special characters and replacing spaces with - or _
01:39 Grinnz_ and truncating after a certain length
01:40 damaya_ yeah, I was more or less going to do some regex stripping replacing all spaces with underscores, then stripping all \W
01:41 damaya_ woo, almost done with this piece of junk... what started out as a one night hackathon app to teach a friend mojolicious and take a break from something more difficult ends up taking nearly a week
01:41 damaya_ haha
01:42 damaya_ in the meantime, I need to get back to work for the evil empire, my employer... Oracle :/
01:45 Grinnz_ ick
01:45 damaya_ Hey, I'm a sellout. They pay me :D
01:45 damaya_ At least I work for what used to be Sun, and I had some respect for Sun
01:45 Grinnz_ heh
01:45 preaction the the_title_here is also called the "slug". make sure they're unique and you don't need the ID
01:45 Grinnz_ yeah, you can do that as well, but then you have to append something at the end in some cases, and store that as the unique key
01:45 Grinnz_ i imagine for a site like reddit at least, looking up by a 6 or 7 char unique key is faster :P
01:46 preaction sure. depends on the use-case. i would avoid applying meaning to the ID if at all possible
01:55 inokenty-w joined #mojo
02:11 tempire Guess I should buy my ticket for yapc
02:11 tempire And learn about phantom
02:11 Grinnz joined #mojo
02:22 diegok joined #mojo
02:39 jberger tempire: \o/
02:40 noganex joined #mojo
02:45 jberger tempire: better hurry, rumor is they are almost sold out
02:45 tempire Yeah, I just read that on the mailing list.
02:45 tempire I'm going to visit http://hatchfamilychocolates.com/
02:45 tempire Apparently it's a thing.
02:46 jberger Looks tasty
03:12 bin_005 joined #mojo
03:22 davido__ joined #mojo
03:27 basic6_ joined #mojo
03:27 cpan_mojo Mojo-Webqq-1.3 by SJDY https://metacpan.org/release/SJDY/Mojo-Webqq-1.3
03:37 cpan_mojo Mojo-Webqq-1.3.1 by SJDY https://metacpan.org/release/SJDY/Mojo-Webqq-1.3.1
03:59 damaya__ joined #mojo
04:00 damaya__ ok, my kid closed irc on me it seems. If anything that might be of interest was said regarding the whole uuid conversation from earlier, I'd really appreciate if someone could PM me and paste it
04:02 Adura /topic
04:03 damaya__ haha
04:03 damaya__ thanks Audra!
04:03 Adura My name isn't Audra.
04:04 damaya__ Weird, somewhere I have a urxvt with irssi running.
04:06 damaya__ Ahh, Adura!
04:06 Adura Heh.
04:06 damaya__ Sorry about that :D
04:06 Adura Ad-TAB is all you need.
04:07 damaya__ yeah, I'm using openbox with no menus, no docks, etc; just hotkeys to launch windows. However, I do have alt-tab and the window is not there, nor is it on another desktop. My kid is a mastermind.
04:07 damaya__ I'm always amazed at the things people with no computer skills can accomplish.
04:10 damaya__ ok, quick question: If I want a route to just render a template, is a callback the most accepted way to accomplish this?
04:10 damaya__ It works, it's how I've always done it, just want to make sure that's the best way to do it.
05:18 buu damaya__: I'd say it depends on the overall flow of the design.
05:18 buu With apps that start breaking out into controllers I prefer to have all of the code in a controller file someplace so I know where to look
05:30 bakanov_da joined #mojo
05:33 nic joined #mojo
05:42 bakanov_da joined #mojo
05:43 bakanov_da joined #mojo
05:46 dod joined #mojo
05:47 dod1 joined #mojo
05:49 ToApolytoXaos joined #mojo
05:51 dod1 joined #mojo
05:56 kaare joined #mojo
06:00 nic damaya_: not sure why you said you couldn't use it for selects - - it's a pk
06:04 damaya__ nic, what do you mean?
06:05 damaya__ the surrogate key, using it in the url?
06:05 damaya__ I don't like to use the surrogate key anywhere that is visible because it gives away information about the database, and I'd rather not do that.
06:07 hypnotoad joined #mojo
06:10 nic damaya__: Is that to thwart people who have direct access to the db?
06:14 hshong joined #mojo
06:19 amon joined #mojo
06:30 t4nk768 joined #mojo
06:30 t4nk688 joined #mojo
06:49 nic joined #mojo
07:00 nic joined #mojo
07:10 nic joined #mojo
07:14 eseyman joined #mojo
07:20 nic joined #mojo
07:24 t4nk926 joined #mojo
07:34 nic joined #mojo
07:51 trone joined #mojo
08:04 damaya__ It's to thwart spammers for example
08:05 damaya__ nic: If I am a spammer and I want to spam comments to posts, I can just put a comment on /p/1 and increment from there /p/2, /p/3, etc
08:05 damaya__ There are many reasons, that's just one
08:09 Vandal joined #mojo
08:21 hypnotoad joined #mojo
08:30 fhelmber_ joined #mojo
08:43 nic joined #mojo
08:44 nic How does one render a file (page.html) which is not under public nor templates?
08:46 bpmedley nic: http://mojolicio.us/perldoc/Mojolicious/Guides/Rendering#Serving-static-files <— This help?
08:46 nic I was thinking: http://mojolicio.us/perldoc/Mojolicious/Guides/Rendering#Rendering-inline-templates
08:47 nic I thought $c->reply->static('foo') needed 'foo' to be in the static path (eg public)
08:48 bpmedley Can you give static() an absolute path?
08:49 nic turns out $c->render(inline => slurp($file)) does the job nicely
08:49 bpmedley Cool stuff; although, I wonder if $file might be interpreted as a template when you don’t want it to be.
08:50 nic I was expecting I'd have to guide it to not try a handler, but it just worked
08:51 nic bpmedley: true, there might be a performance gain by skipping the ep step
08:52 nic I'm guessing ->render(data => slurp(..)) could be made to work if I gave it more information
08:52 bpmedley Have you tried an absolute path to static()?
08:52 * nic tries
08:57 nic bpmedley: I can't make that work
08:57 nic just getting 'not found'
08:57 nic I'm wondering about something like $c->render(inline => slurp($file), handler => undef)
08:58 nic Well, it works, but not sure if the undef is achieving anything
09:10 t4nk192 joined #mojo
09:20 sri it's not
09:20 sri and how did you miss http://mojolicio.us/perldoc/Mojolicious/Guides/Rendering#Custom-responses
09:21 sri ?
09:22 sri inline is actually a feature of the handler
09:25 * sri keeps forgetting to make a failing test case for DBD::Pg :S
09:25 sri someone remind me later!
09:25 bin_005 joined #mojo
09:25 sri (or better yet... make one!)
09:26 sri https://github.com/kraih/mojo-pg/issues/3
09:27 sri it needs to simulate two async queries right after another with a fake IO::Poll event loop
09:27 sri the socket will not become readable again for the second query
09:36 nic sri: Thanks, that's exactly it.  Nothing wrong with the docn; I read it yesterday for something else (pdf), but my brain didn't register that this is exactly the same thing
09:42 Dandre1 hello
09:43 Dandre1 How can I redirect to the not_found template in another template where some condition doesn't match?
09:45 icjs joined #mojo
09:50 nic Dandre1: It's unusual (probably bad practice) to have that level of logic in a template
09:51 nic Can't you check the condition in the controller before you enter the template?
09:57 Dandre1 I have a route defined like /foo/:id that is redirected to my template. I wanted to check in my template whether the id passed exists and call the not_found template
09:58 Dandre1 I don't have a dedicated controller for that route
10:06 kyshtynbai joined #mojo
10:16 nic If you're wanting to avoid having a .pm for the controller, you could use an inline callback
10:54 neilhwatson joined #mojo
11:01 ivan_ joined #mojo
11:27 bpmedley joined #mojo
11:33 xdg joined #mojo
12:12 Dandre1 ok
12:53 icjs2 joined #mojo
13:01 zivester joined #mojo
13:04 ToApolytoXaos joined #mojo
14:12 zackiv31 joined #mojo
14:24 asarch joined #mojo
14:28 mattastrophe joined #mojo
14:29 AndrewIsh joined #mojo
14:35 mattastrophe joined #mojo
15:05 mrEriksson joined #mojo
15:15 PryMar56 joined #mojo
15:23 bpmedley_ joined #mojo
15:29 kyshtynbai joined #mojo
15:42 inokenty rfhfekgtnhjdbx
15:43 jberger qwertyuiop
15:44 Kogurr joined #mojo
16:16 sh4 joined #mojo
16:44 mattastrophe joined #mojo
17:11 genio joined #mojo
17:24 Grinnz joined #mojo
17:32 fhelmber_ joined #mojo
17:43 bpmedley_ joined #mojo
17:45 amon joined #mojo
17:49 berov joined #mojo
17:51 dod joined #mojo
18:01 inokenty-w joined #mojo
18:16 disputin joined #mojo
18:18 fhelmber_ joined #mojo
19:14 fhelmber_ joined #mojo
20:06 disputin joined #mojo
20:11 Ptolemarch joined #mojo
20:20 cpan_mojo Mojo-IRC-0.24 by JHTHORSEN https://metacpan.org/release/JHTHORSEN/Mojo-IRC-0.24
20:39 ToApolytoXaos joined #mojo
21:01 Ptolemarch joined #mojo
21:27 Ptolemarch joined #mojo
21:37 guru joined #mojo
21:46 PryMar56 joined #mojo
22:43 bobkare joined #mojo
23:07 damaya_ joined #mojo
23:07 damaya__ joined #mojo
23:42 mattastrophe joined #mojo

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary