Skip to content

Instantly share code, notes, and snippets.

View astout's full-sized avatar

Alex Stout astout

View GitHub Profile
@astout
astout / count_lines.sh
Last active December 8, 2020 15:49
List number of lines in a file or in all files in a directory (non-recursive). Data is outputted in neat columns.
# author: Alex Stout
# check if the provided argument is a directory
if [[ -d $1 ]]; then
: # nop -- do nothing
elif [[ -f $1 ]]; then # or is it a file
: # nop -- do nothing
else
echo "argument is invalid"
exit 1
@astout
astout / 200221-grading.md
Last active February 22, 2020 05:24
200221 Grading
@astout
astout / 200220-grading.md
Created February 21, 2020 06:47
200220 Grading
@astout
astout / thinkful_css.md
Last active October 7, 2018 19:49
Thinkful CSS Response

CSS

Hi student,

No sweat. You're so close! It looks like you're not using flexbox which is definitely the recommended way to layout and center content. I'm going to give you a couple pieces because you're pretty much there. First, notice your pricing element is overflowing. This is because you're unnecessarily providing width: 100%, let's let the defaults handle the width here and remove that, width: 100%. This will allow the width of pricing to fill its parent without regard for the width of its own child content. Next, let's use flexbox by adding display: flex to your pricing element.

And voilà ! That should render your .pricing-tiers within the .pricing element. Does this look how it should? Definitely play around a bit with flexbox and let me know if you have anymore questions!

@astout
astout / thinkful_algorithms.md
Created October 7, 2018 19:45
Thinkful Algorithms Response

Algorithms

Hi student,

What I found most helpful when I was learning Big-O notation was to always think of it like this. Simply, Big-O notation is

How execution time scales with respect to size N of the dataset.

Here are some basic examples of different notations.

@astout
astout / thinkful_frameworks.md
Created October 7, 2018 19:43
Thinkful Frameworks Response

Frameworks/Libraries

Hi student,

Welcome to one of modern web development's most polarizing debates!

Is React a framework or a library?

According to Facebook, React is a JavaScript library. One way to think of a library is that a library is something that provides an interface to make your top-level design simpler and cleaner. I hope you are familiar with the design concept MVC (Model, View, Controller), if not, I enjoy this simple explanation from the perspective of web development.

@astout
astout / thinkful_sql.md
Created October 7, 2018 19:41
Thinkful SQL Response

SQL

Hi student,

SQL Injection is definitely a security flaw you'll always want to keep in mind when writing web applications that use SQL databases. SQL injection occurs when SQL queries are performed using standard string interpolation. Any language that supports SQL should also provide SQL libraries that provide methods to safely construct and execute SQL queries using some type of parameter sanitation method or parameter binding.

SQL Injection Examples

First, I'll show some examples of SQL injection in practice.

@astout
astout / thinkful_rails.md
Created October 7, 2018 19:39
Thinkful Rails Response

Rails

Hi student,

First, I'm glad to hear you're making progress learning Rails ActiveRecord associations. Second, before you consider yourself stuck, I would always recommend seeking out code documentation. Most good modern software has helpful documentation that should be able to steer you in the right direction. The Rails documentation has a great example on has_many :through associations. Let's use their example.

has_many tells ActiveRecord that we want each instance of this model to have associations to one or more instances of another model. Now imagine we want to simply access data of a third model that is referenced only by association of our referenced model from our first model (sorry that was a mouthful). This is where :through comes into play. Consider the following:

class Physician < ApplicationRecord
@astout
astout / thinkful_js.md
Created October 7, 2018 19:38
Thinkful JS Response

JavaScript

Hi student,

Sure! This is actually a pretty common problem that everyone encounters at some point in web development. This is what is known as a "scope" issue. Scope is essentially the environment that is known to the software at a given time of execution. What is happening in your example, is that when your onclick function is executed, it's a different scope than the prizes and btnNum variables. By the time the onclick executes, prizes and btnNum are long gone. The onclick function doesn't "know" about these variables. These variables are out of the scope of the onclick function.

So to fix this, there are a few things you can do. I've written about a few of the other methods that could be used in some further reading, but for simplicity I only included the solution I would recommend here.

Set onclick Function on HTML elements

@astout
astout / thinkful_js_further_reading.md
Created October 7, 2018 19:36
Thinkful JS Further Reading

JavaScript (further reading)

Here are a few solutions for when the onclick function is trying to access out-of-scope data.

Function Returns A Function

This one is probably the most confusing, but functions that return functions is a common practice in JavaScript, so it's something you'll want to get familiar with. You can create a function that knows the full scope of what you need and returns a unique function that calls the alert with a given text.

function getPrizeFunction(prizeText) {