|
EVGA Longoria posted:I have A ranks there, if you actually care about that. What does this mean?
|
# ? Apr 3, 2015 12:49 |
|
|
# ? May 15, 2024 02:54 |
|
MALE SHOEGAZE posted:What does this mean? CodeClimate grades your code from F to A based on some heuristics. With an A being the "best".
|
# ? Apr 3, 2015 17:51 |
|
MALE SHOEGAZE posted:What does this mean? CodeClimate grades your code quality based on "code smells" - i.e. repeated code, complex methods, lots of parameters, things like that. None of it is hard and fast rules to code quality. It's kind of fun to look at, and it helps identify some good refactor points. That's about it. DSLs tend to get poo poo on by CodeClimate because they involve a lot of code outside of methods, That means Sinatra usually has low grades.
|
# ? Apr 3, 2015 17:52 |
|
kayakyakr posted:As an extension of this conversation, I need to create a bearer-type token for dumb API access. The scripts that will use this are generally dumb, scheduled curl scripts so that oauth-style challenge/expiring tokens are not an option. I don't want to store the key on the DB as it would be an unhashed password. I can't hash it and store it because I need to be able to re-display the key through the interface. When I have to do this, I generate two random strings of a fixed length: token-key and secret. Store the token-key in a column with a unique constraint, and the bcrypt of the secret. If you just want the client to see the simplicity of a single string, concatenate them. To look up the user from the token, split it, find based on key, and match the bcrypt(secret). Don't expose primary keys or anything like that to users, they'll do something fucky.
|
# ? Apr 4, 2015 05:24 |
|
EVGA Longoria posted:CodeClimate grades your code quality based on "code smells" - i.e. repeated code, complex methods, lots of parameters, things like that. None of it is hard and fast rules to code quality. You should really never be writing a DSL unless you're writing a gem or library intended for consumption by unknown entities. You have to generalize a solution beyond what is practical or necessary for your own uses, and the work involved in writing your stupid declarative methods is not worth it when all you need to be doing is writing an interface and saying 'hey if you want to use this library, your classes need to provide these interfaces'
|
# ? Apr 4, 2015 23:59 |
|
MALE SHOEGAZE posted:You should really never be writing a DSL unless you're writing a gem or library intended for consumption by unknown entities. You have to generalize a solution beyond what is practical or necessary for your own uses, and the work involved in writing your stupid declarative methods is not worth it when all you need to be doing is writing an interface and saying 'hey if you want to use this library, your classes need to provide these interfaces' Not talking about writing a DSL. Talking about using a DSL (Sinatra) getting penalized by CodeClimate.
|
# ? Apr 5, 2015 06:19 |
|
I need to process a string word by word and see if certain words match a condition, then compile the string back together. Basically, I am pulling social media posts and want #s and @s to show up in blue. Does anyone have any experience doing something like this? In that past, I would probably use something like PHP's explode() function, but perhaps there are more elegant methods.
|
# ? Apr 6, 2015 16:30 |
|
Buckhead posted:I need to process a string word by word and see if certain words match a condition, then compile the string back together. Basically, I am pulling social media posts and want #s and @s to show up in blue. If you want to avoid using gsub, you could split and then join the string: Ruby code:
|
# ? Apr 6, 2015 17:00 |
|
Anyone know of a gem that guesses at word/phrase abbreviation? I've got to turn team names into abbreviations in some sort of clever way. Say, Texas Tech University would become TTU while Wisconsin would become Wisc. If not, it shouldn't be too hard to create. Multiple words just take the first letter of each word (leaving out a, of, and, to, the, and any other short words that don't generally get capitalized). Single words just take the first 4 letters.
|
# ? Apr 6, 2015 18:20 |
|
Buckhead posted:I need to process a string word by word and see if certain words match a condition, then compile the string back together. Basically, I am pulling social media posts and want #s and @s to show up in blue. Ruby code:
edit: okay I must have opened this tab a long time ago and never looked at it MasterSlowPoke fucked around with this message at 18:35 on Apr 6, 2015 |
# ? Apr 6, 2015 18:32 |
|
quote:# Use a set for O(1) include?
|
# ? Apr 6, 2015 18:45 |
|
Gmaz posted:That's nice, never realized this. Yeah, its implemented as a Hash underneath, so anything looking for a specific value just maps to a hash key.
|
# ? Apr 6, 2015 19:12 |
|
necrotic posted:If you want to avoid using gsub, you could split and then join the string: Very cool, thank you! Haven't had a chance to test fully but I see what are you doing here.
|
# ? Apr 6, 2015 22:03 |
|
I have a table that tracks which users have access to which resources, so it's just user_id and resource_id. I want to introduce a function where an admin can give 5 random users access to a given resource. I'm trying to think through the most efficient way to find 5 users that don't already have access to the resource. I know exactly how I'd write this in SQL but I can't think of a way to make this "rails-y". I would do:code:
|
# ? Apr 20, 2015 00:07 |
|
I did something like this in a demo appcode:
code:
|
# ? Apr 20, 2015 00:56 |
|
Excellent, thanks. I'll play around with this.
|
# ? Apr 20, 2015 01:36 |
|
EVGA Longoria posted:Not talking about writing a DSL. Talking about using a DSL (Sinatra) getting penalized by CodeClimate. If your Sinatra app is big enough that you are bothering to use Code Climate on it and care about your grade, make it a Rails app.
|
# ? Apr 20, 2015 22:09 |
|
Cocoa Crispies posted:If your Sinatra app is big enough that you are bothering to use Code Climate on it and care about your grade, make it a Rails app. Sinatra is a great choice for large applications. Well, the HTTP server and router part of it.
|
# ? Apr 20, 2015 23:47 |
|
Cocoa Crispies posted:If your Sinatra app is big enough that you are bothering to use Code Climate on it and care about your grade, make it a Rails app. nope rails sucks I say as I'm on a flight to railsconf
|
# ? Apr 21, 2015 00:32 |
|
Pardot posted:nope rails sucks I say as I'm on a flight to railsconf you suck where's railsconf this year?
|
# ? Apr 21, 2015 03:10 |
|
kayakyakr posted:you suck where's railsconf this year? ATL I should've gone considering its right around the corner. Oh well!
|
# ? Apr 21, 2015 13:52 |
|
I am being returned a hash from an API with two identical keys. I need to save the first and second value to separate variables.code:
code:
|
# ? Apr 21, 2015 17:33 |
|
Buckhead posted:I am being returned a hash from an API with two identical keys. I need to save the first and second value to separate variables. Looks like it will always be two values, so I'd just do this: Ruby code:
Also, there's Enumerator#each_with_index so you don't have to increment your own counter. necrotic fucked around with this message at 18:14 on Apr 21, 2015 |
# ? Apr 21, 2015 17:57 |
|
Thank you necrotic! You guys are awesome. Always good to learn these new functions. edit: I also emailed the designers of that specific API and told them to have unique endpoints. Seems like bad design to rely on the order of the hash, rather than specific endpoints. Buckhead fucked around with this message at 20:40 on Apr 21, 2015 |
# ? Apr 21, 2015 19:35 |
|
Anybody have ideas about how to serve assets from S3, but using a relative path, aka faking that they're served from my web app? I'm trying to use pano2vr player to build an HTML5 Virtual tour, and it requires that the images and XML file that builds the tour be served from the same directory, on my app.
|
# ? Apr 21, 2015 21:31 |
|
I have done something similar to that before, using an assets controllercode:
|
# ? Apr 21, 2015 21:46 |
|
Drogadon posted:I have done something similar to that before, using an assets controller Nice, thank you. All I need is for the XML file that the pano2vr player reads to have relative paths to the source images. For example, this is what the XML looks like code:
|
# ? Apr 21, 2015 21:51 |
|
This is a completely crazy bug but I have no idea what the hell. Code changes I make to models don't get loaded unless I completely exit my shell. My workflow is normally: 1. open terminal 2. rails s 3. develop, change stuff, reload page 4. happiness Now I have this bug where stuff won't update in server mode or console. So no my workflow is 1. open terminal 2. rails c 3. load object 4. object.some_relationship #bugs out here saiyng the relationship doesn't exist 5. exit console, exit terminal 6. launch terminal, rails c 7. object.some_relationship #works now, but only after a terminal exit So I have to completely exit the terminal if I make changes in my text editor. What the hell? e: Fixed it, changed some init settings and it started working. Wierd that it required me to exit the terminal though. I think it was fixed by remove config.reload_classes_only_on_change = false KoRMaK fucked around with this message at 03:48 on Apr 24, 2015 |
# ? Apr 24, 2015 03:31 |
|
KoRMaK posted:e: Fixed it, changed some init settings and it started working. Wierd that it required me to exit the terminal though. I think it was fixed by remove config.reload_classes_only_on_change = false Yeah that setting will do it. And rails will only reload files from app/ and lib/, config/ file changes require a full reboot of the app. Not sure why you had to exit your terminal (I assume you mean like Terminal.app or iTerm2.app, not the rails console).
|
# ? Apr 24, 2015 14:27 |
|
I'm trying to use cancancan in my mailer views, but apparently "can?" isn't being included. How do I get can included on a mailer? I've tried including it via a helper and require but o luck. e: NM, I got it. Just had to delegate to it in the helper. KoRMaK fucked around with this message at 21:39 on May 1, 2015 |
# ? May 1, 2015 21:24 |
|
Security-ish question. I'm currently working on a migration path for users of a few largely similiar legacy apps into this one new system. Since a user may have had an account on multiple sites and for Business Reasons the auth system has changed I need a mechanism for users to 'claim' their old accounts and merge the data into their new one. I've got the merging part in place and unit tested and whatnot but I wanted to make sure my idea for the workflow for it is sound. Basically, like how a password reset might go
|
# ? May 2, 2015 23:19 |
|
What happens if Alice puts Bob's email address in the "user fills in the email address of the old account" step?
|
# ? May 3, 2015 04:10 |
|
Tao Jones posted:What happens if Alice puts Bob's email address in the "user fills in the email address of the old account" step? Seems like Bob would get an email asking him to claim his account? That's fairly close to a reset password flow, which is fairly standard.
|
# ? May 3, 2015 04:17 |
|
kayakyakr posted:Seems like Bob would get an email asking him to claim his account? Yeah, that's what I was going for. There'd be some warning text, and it could check that the user who originated it is the same one who clicked the link.
|
# ? May 3, 2015 04:33 |
|
kayakyakr posted:Seems like Bob would get an email asking him to claim his account? Ah, okay. From the way I was reading the flow, it seemed like there'd be an AccountClaim with Alice's user_id and Bob's email address, which might be dangerous if Alice is evil and tricks Bob.
|
# ? May 3, 2015 04:40 |
|
The Milkman posted:Security-ish question. Why not just automatically migrate everyone and let them login with their old passwords?
|
# ? May 5, 2015 01:18 |
|
Sil posted:Why not just automatically migrate everyone and let them login with their old passwords? secret key used to hash the passwords is going to be different across the legacy apps. Hashing methodology might not even be compatible. You could create users and merge accounts automatically keying on email and just force users to reset their password when they try to sign up with an email already in the system, though.
|
# ? May 5, 2015 01:30 |
|
I got 99 problems and RVM is one. So I open up the terminal (on Ubuntu 14.04) and: code:
This is happening after I pull an update of the app from the repo and ran: rvm install 2.2.2 rvm use 2.2.2 - default bundle install. Now I have to run rvm use 2.2.2 every drat if I want to work on the app, before that everything worked fine. I don't have much experience with RVM since I use rbenv on other computers, and basically I have no idea WTF is going on whatsoever. Gmaz fucked around with this message at 15:08 on May 11, 2015 |
# ? May 11, 2015 15:02 |
|
add a .ruby-version and .ruby-gemset file to root of your project. Now it'll switch to the proper ruby and gemset every time. (note: requires RVM to be properly installed in your shell profile)
|
# ? May 11, 2015 15:11 |
|
|
# ? May 15, 2024 02:54 |
|
You could also try rvm get stable --auto-dotfiles If you don't mind it mucking with your dotfiles and just want to be fairly sure it's getting loaded properly. It doesn't do anything obnoxious in my experience
|
# ? May 11, 2015 15:18 |