William Kennedy

Joined

28,280 Experience
244 Lessons Completed
5 Questions Solved

Activity

Posted in How do I transfer user data on delete

You may have to divide and conquer the steps first. 

1. Identify the users you want to delete
2. Identify the employee
3. Transfer id
4. then delete user

depending on the table, you could use SQL to a large update provided you're able to find the users


UPDATE employees
LEFT OUTER JOIN user
    ON "{your condition}"
SET  employee.foreign_key = user.foreign_key
WHERE {condition}

I know it's not an exact answer but might point you in the right diraction


Posted in Can anyone suggest me best Ruby on Rails 5 book?

Rails Tutorial by Hartl is one that springs to mind. I also recommend Agile Development with Rails by Sam Ruby and Dave Thomas and DHH. After you build a few things, you will quickly get the hang of it

Posted in How do I generate dynamic classes?

Ya I was looking at that but then I found this cool library that accomplished what I wanted. 

https://github.com/digitaledgeit/sass-spacing

I'm play around with it some more and see if I can come up with a robust solution. 

Posted in How do I generate dynamic classes?

Is there a way to generate dynamic classes with scss/sass? For example, in my HTML. I want to write 

div class='mt-10'></div>
div class='mt-7'></div>
div class='mt-3'></div>

This should create a div that has a margin-top of 10px, 7px, 3px and I imagine the CSS will look like this:

.mt-{x} {
  margin-top: x;
}

Any help appreciated?



Posted in Writing Tests for Rack Middleware Discussion

Great video Chris. 

Posted in Open Closed Principle Discussion

Quick question Chris, when you were building out functionality like this for Hatch, how much of this structure do you plan versus how much did you arrive at through refactoring and iteration? 
Hi Arjun,

You could use normal JS with the setInterval method. Something like this: 

function timer(seconds){
    clearInterval(countdown);
    displayRemainingTime(seconds);
    const then = Date.now() + seconds * 1000;
    countdown = setInterval(() => {
        const secondsLeft = Math.round((then - Date.now()) / 1000);
        if(secondsLeft < 0) {
            clearInterval(countdown);
            return;
        }
        displayRemainingTime(secondsLeft);
    }, 1000)
}

function displayTimeLeft(){
 //update dom
}


I did something like this as part of a Javascript 30 course by Wes Bos. Recommend checking it out

William

Here is how I achieved the same effect using bootstrap 3. There is a div for each icon essentially. For font-awesome, you would just need to use the i class in the div. Hope that helps. 

<div class="input-group">
<div class="input-group-addon">€</div>
<%= f.text_field :field, class: 'form-control' %>
<div class="input-group-addon">.00</div>
</div>

Posted in Data Structure - Going back to the basic with Ruby

Hi Kelvin,

Let me try and put my own perspective

1 - Solid understanding of programming and computer science fundamentals. What do they want me to know?
Cracking the coding interview book
2 - Data Structure (list, stack, array, tree). 
Cracking the coding interview book
3 - With the data structure, how to search and sort with them. Best ways of searching and sort.
Cracking the coding interview book
4 - Understand the Big Oh problem and how to identify and solve it.
Cracking the coding interview book

Another topic that companies are asking for Senior Position (one day in the future)

5 - API design technique. What would it be?
Depends what the API does but I have built a few in the past and I wish I approached things differently. Here's a book I've been meaning to read http://apionrails.icalialabs.com/

6 - Strong familiarity with principles of database design and architecture. 

Refactoring Ruby, Code Complete etc...

7 -  Familiarity with OWASP and/or other web security practices.

Not sure but Handbrake is a useful gem for spotting security problems. That's I learned about security. 

8 - Knowledge of optimization tactics such as query optimization and caching

Rails Performance is a great course that covers Rails Performance in-depth https://www.railsspeed.com/ and Chris has a few videos on here as well. 

Hope that helps,
William

Posted in 'bcrypt' gem install Error

Your welcome but I think it was you who did all the work. Glad it's working. 

Posted in Building A Hosting Platform in Ruby Discussion

Cool presentation Chris. I was actually wondering how you managed env variables on hatch. I assume, they are saved in the HatchBox app and a script gets runs to update the .rbenv-vars-file or am I way off the mark? 

Posted in 'bcrypt' gem install Error

It looks like you are missing some development packages or dependencies.


sudo apt-get install ruby-dev
 

Are you on a mac? You may also need the command line tools. 

brew doctor can help in these situations.

For competitive reasons, if an orders id is present in the form via inspect element, the competitor is able to guess how many transactions have been done.

That is the main reason.

Perfect. I will stick with friendly id. Another question just to follow on from that. What about hiding the id in forms.

In this case the the id attribute has the id of the order. I am looking at gem called obfuscate id but it seems deprecated. This is a Rails 5 app.

What would be the best practice in this case?

What is the best way to generate SEO friendly urls?

The Rails default is to put the id in the URL e.g articles/2

I want to be able to have a url like this

articles/article-heading

Previously I have used the to_param method to generate a custom url as well as a gem called Friendly_id

I am just wondering if anyone has any other suggesstions on best practices