Skip to content

Instantly share code, notes, and snippets.

View SteveOscar's full-sized avatar

Steven Olson SteveOscar

View GitHub Profile
@SteveOscar
SteveOscar / package-management.markdown
Last active March 24, 2016 17:57 — forked from rrgayhart/package-management.markdown
Code You Don't Control (WITH A GEM, UGHHHH!) - SteveO Responses

Checks for Understanding

Fork this Gist and Respond to the Following Questions

  • In broad strokes, summarize the event
    • A developer had released serveral packages on NPM that many programs used as a dependency, including major stuff like Babel. One of these packages was basically a simply formatting function called Kik. A large messaging comapny has that same name, and wanted to release a package called 'Kik'. They contacted the developer and offered compensation if he changed the name, lawyers at his door if he didn't. He refused, and pulled all of his packages from NPM, breaking many dependent programs in the process. NPM decided for the first time to un-unpublish a module.
@SteveOscar
SteveOscar / speaking_js.md
Created March 18, 2016 20:37
Speaking Javascript

####Which sections were interesting?
I was interested by the idea of using IIFE's to avoid creating variables in the global scope, as variable scope was something I struggled with on my personal project. I was also interested by the idea of binding an extracted method to its original object.

####Which sections did you totally skim?
Chapter 17 was a burnout. I started reading it, but it's just too dense and long to retain much information. I think it might be valuable to go back to and refer to later once we have a better JS foundation, but right now, it's a bit overwhelming.

####Do you think the reading was valuable?
Yes, except for the last chapter. But I also think that reading without exercising the new concepts is fairly useless, so it's kind of on us to make the most of the reading by trying out examples in the console.

####Which topics were notably confusing?

@SteveOscar
SteveOscar / sandi.md
Created March 16, 2016 14:55
Sandi Metz' 5 rules

#####Only instantiate one object in the controller.

This rule was the most interesting to me, and the one I initially mentally rejected, as it seems like it would often be impractical. But after looking further at how the implemented it, by creating a dashboard PORO with different methods to access multiple types of information, it is an interesting setup.

#####Each method should only have 5 lines.
About the 5-line methods rule - ff course in general it's good to keep methods as short and simple as possible, but I think that trying to squeeze every method into this rule will result in a lot of unreadable code using dense ternary statements, etc.

@SteveOscar
SteveOscar / js_exercisms.md
Created March 15, 2016 20:51
JavaScript Exercisms

Leap

My Code

Other Solutions

  1. Solution 1 - This solution is similar to mine in how the person used the logic without an if/else statement, but the groupings of the && and || statements is different. But it produces the same results.
  2. Solution 2 - This person used a baseline false return, which seems unnecessary as long as the code covers and required possibilities. This person also used if/else statements, which is not needed.
  3. Solution 3 - This person did not complete the exercise, as they have only checked for divisibility by 4, and have not create an isLeap function.
  4. Solution 4 - This person used the same basic logic that I used, also choosing to not use an i
@SteveOscar
SteveOscar / 03-16-blog.md
Last active March 7, 2016 17:35
Building an interactive map using jVectorMap

Creating an Interactive Map With jVectorMap

Background

  • I've been using this JS library to build my mod-3 personal project.

Setting Up the Map

  • Downloading the correct files
  • Where to place the files in your Rails app

GlobeSquatter (working title)

Pitch

A mapping application that allows a user to quickly see trends and current realtive expenses in countries around the world.

Problem

There are plenty of databases and static maps showing relative costs across countries, but it's hard to get a big-picture view without visiting multiple sites. Also, most reports and maps focus on USD and EUR as the base currencies. It's difficult for people earning more obscure currencies to find data from their perspective.

###The Turing Firehose of Information
#How Mod2 is different from Mod1
-logic overload vs tools overload
-pros and cons
#Reactions of myself and classmates
-Not sure what to focus on
-Balancing keep up vs retention of past topics
-
@SteveOscar
SteveOscar / github_shortcuts.md
Last active January 7, 2016 16:49
Github Shortcuts

'?' - brings up shortcut list
'g+d' - go to your dashboard
'g+c' - go to repo root
'j' - move selection down
'k' - move selection up
'o' - open selection
't' - open file finder for project
's' - put curser in search bar

@SteveOscar
SteveOscar / basic_polymorphic.rb
Created December 30, 2015 18:06
Basic Polymorphic Association
class Tag < ActiveRecord::Base
belongs_to :taggable, polymorphic: true
end
class Article < ActiveRecord::Base
has_many :tags, as: :taggable
end
class Newspaper < ActiveRecord::Base
has_many :tags, as: :taggable
# First, the new join table, where 'taggable' establishes the polymorphic association.
class Tagging < ActiveRecord::Base #the join table
belongs_to :tag
belongs_to :taggable, :polymorphic => true #this line sets up polymorphism
end
# The tag model is associated with newspapers AND articles (polymorphism) via the join table.
class Tag < ActiveRecord::Base
has_many :newspapers, :through => :taggings, :source => :taggable,
:source_type => "Newspaper" # informs rails how to get to newspapers from tags