Keyboard shortcut for Highlighting Current Line?
Is there a Keyboard shortcut for highlighting one line? Why not? How can I make one? Thanks.

tannertan36
will byers stan first human second

祝日 / Permanent Vacation

PR's Tumblrdome
ojovivo
2025 on Tumblr: Trends That Defined the Year
$LAYYYTER
wallacepolsom
PUT YOUR BEARD IN MY MOUTH
we're not kids anymore.
styofa doing anything
Mike Driver
Lint Roller? I Barely Know Her
🪼
Monterey Bay Aquarium

if i look back, i am lost

Kaledo Art

★

JBB: An Artblog!
Alisa U Zemlji Chuda

seen from Germany

seen from United States

seen from United States

seen from Germany
seen from United States
seen from Germany
seen from Türkiye

seen from Türkiye

seen from United Kingdom
seen from United States
seen from Italy
seen from United States

seen from Germany
seen from Canada
seen from United States

seen from United Kingdom
seen from United States
seen from United Kingdom

seen from Kenya
seen from United States
@flatironschoolfellowship
Keyboard shortcut for Highlighting Current Line?
Is there a Keyboard shortcut for highlighting one line? Why not? How can I make one? Thanks.
Questions All Ruby Developers Should Be Able to Answer!
# Ruby Questions
* What is a class? - Classes are a blue-print for constructing computer models for real or virtual objects. - Classes hold data, have methods that interact with data, and are used to instantiate objects.
* What is an object? - An instance of a class. To some it's also the root class in ruby.Classes themselves descend from the object root class. * What is a module? Can you tell me the difference between classes and modules? - Modules serve as a mechanism for namespaces. -Also, modules provide as a mechanism for multiple inheritance via mix-ins and cannot be instantiated like classes can.
* Can you tell me the three levels of method access control for classes and modules? What do they imply about the method?
- All methods, no matter the access control can be accessed within the class But what about outside callers? - Public methods enforce no access control -- they can called in any scope. - Protected methods are only accessible to other objects of the same class. - Private methods are only accessible within the context of the current object.
* There are three ways to invoke a method in ruby. Can you give me at least two? - There is the dot operator (object.object_id) - There is the Object#send method (object.send(:object_id)) - method(:foo).call (object.method(:object_id).call
* Explain this ruby idiom: a ||= b A common idiom that strong ruby developers use all the time.
A || a =b this means that a == b when a == false.
* What does self mean?
self always refers to the current object. But this question is more difficult than it seems because Classes are also objects in ruby.
# More Ruby Questions
* What is difference between unit, functional, integration testing? - Unit testing, simply put, is testing methods -- the smallest unit in objectoriented programming. Strong candidates will argue that it allows a developer to flesh out their API before it's consumed by other systems in the application.The primary way to achieve this is to assert that the actual result of the method matches an expected result.
* Tell me about the Ruby Object Model. - Almost everything in Ruby is an object. The Ruby object model explains why that is: - http://www.hokstad.com/ruby-object-model * What happens when you include a module on a class? What about extending a module on a class? Why? * What happens when you include a module on an instance? What about extending a module on an instance? Why?
* What is a Proc? - People confuse procs with blocks. Essentially, Procs are anonymous methods( or nameless functions) containing code. They can be placed inside a variable and passed around like any other object or scalar value. They are created by Proc.new, lambda, and blocks(invoked by the yield keyword).
# Rails Questions
* What is a named scope? - A scope is a subset of a collection. Sounds complicated? It isn't. Imagine this:
You have Users. Now, some of those Users are subscribed to your newsletter. You marked those who receive a newsletter by adding a field to the Users Database (user.subscribed_to_newsletter = true). Naturally, you sometimes want to get those Users who are subscribed to your newsletter.
You could, of course, always do this:
User.where(subscribed_to_newsletter: true).each do #something Instead of always writing this you could, however, do something like this.
#File: users.rb class User < ActiveRecord::Base scope :newsletter, where(subscribed_to_newsletter: true) #yada yada end This allows you to access your subscribers by simply doing this:
User.newsletter.each do #something This is a very simple example but in general scopes can be very powerful tools to easy your work.
Check out this link: API Desciption http://stackoverflow.com/questions/4869994/what-is-scope-named-scope-in-rails
* What is the difference between includes and joins. - :joins joins tables together in sql, :includes eager loads associations to avoid the n+1 problem (where one query is executed to retrieve the record and then one per association which is loaded).
I suggest you read their sections in Rails Guides to get more info: -http://stackoverflow.com/questions/4861416/whats-the-difference-between-includes-and-joins-in-activerecord-query * How would you implement basic caching? - http://guides.rubyonrails.org/caching_with_rails.html * How about partial page caching? - http://guides.rubyonrails.org/caching_with_rails.html
* What is a polymorphic association? - In Rails, Polymorphic Associations allow an ActiveRecord object to be associated with multiple ActiveRecord objects. A perfect example for that would be comments in a social network like Facebook. You can comment on anything on Facebook like photos, videos, links, and status updates. It would be impractical if you were to create a comment model (photos_comments, videos_comments, links_comments) for every other model in the application. Rails eliminates that problem and makes things easier for us by allowing polymorphic associations. -http://terenceponce.github.io/blog/2012/03/02/polymorphic-associations-in-rails-32/
* What is a has and belongs to many association? - A belongs_to association sets up a one-to-one connection with another model, such that each instance of the declaring model "belongs to" one instance of the other model. - A has_many association indicates a one-to-many connection with another model. You'll often find this association on the "other side" of a belongs_to association. This association indicates that each instance of the model has zero or more instances of another model.
http://guides.rubyonrails.org/association_basics.html
* What is Rack - Rack is a nice Ruby-fied replacement for CGI. Rack sits between all the frameworks (Rails, Sinatra, Rulers) and all the app servers (thin, unicorn, Rainbows, mongrel) as an adapter.
Rack is a convenient way to build your Ruby app out of a bunch of thin layers, like a stack of pancakes. The layers are called middleware. Or pancakes, why not? -http://codefol.io/posts/What-is-Rack-A-Primer
* What is the purpose of Active Record?
- Active Record serves as a way to retrieve data from the database. * What is the purpose of Active Support? - * What would you store in a Session?
-Rails uses a CookieStore to handle sessions. What it means is that all the informations needed to identify a user's session is sent to the client and nothing is stored on the server. When a user sends a request, the session's cookie is processed and validated so rails, warden, devise, etc. can figure out who you are and instantiate the correct user from the database. Cookies are how server can remember who you are from one request to another. Everytime you send a request to a server, you send every cookie you have for that domain. Nothing new here. A session cookie is signed and encrypted (encryption is new in Rails 4) then sent to the browser. That cookie is actually an hash that would look like this if you run something like Warden and Devise:
- http://www.andylindeman.com/2013/02/18/decoding-rails-session-cookies.html
# General Questions
* What is HTTP?
* Explain is as much possible detail what happens when you make a request in your browser. * Explain REST * What is a HTTP response for? * What is a HTTP request for? * What does it mean for a request to be idempotent? What types of requests are idempotent? * What are cookies for? * Explain inner, outer, left and right joins.
[1]: https://gist.github.com/austenito/5810643 [3]: http://www.codinghorror.com/blog/2007/10/a-visual-explanation-of-sql-joins.html
Very Important
You can switch tabs in chrome by pressing Ctrl+Tab. That is all.
Selector Gadget!
I was watching a tutorial on Nokogiri and found the a great tool for selecting CSS. It's a chrome extension called "selector gadget". All you have to do is highlight an element and it tells you the selector and it's path. It also allows you to subtract elements that you might not want. This is perfect for JQuery and Nokogiri and it looks like this
In the bottom right window you will see that the title selected is an .h2 element. All of this without opening your "inspect element." It's awesome. Download for free here: https://chrome.google.com/webstore/detail/selectorgadget/mhjhnkcfbdhnjickkkdbjoemdmbfginb?hl=en
Adding Bootstrap to a Rails Project
Today my group charged me with adding Bootstrap to our project since we are close to design time.
Like with everything Rails made it pretty easy.
First you must add the gem to the gem file, along with a 'rails_layout' gem that we do not need during production.
gem 'bootstrap-sass' group :development do gem 'rails_layout' end
And then we must set up
$ rails generate layout:install bootstrap3 --force
and boom we're off (the force argument gets rid of any existing files in case you're wondering).
Creating a Simple Gem
A ruby gem is a program or library that can be installed through your computer using the RubyGems package manager. Gems are usually built from ".gemspec" files, which are YAML files containing information on Gems. However, Ruby code may also build Gems directly.
I used this http://guides.rubygems.org/make-your-own-gem/ tutorial to build my gem.
The guide can be found here: http://guides.rubygems.org/make-your-own-gem/
You'll find that all RubyGems have these 3 components
Code (including tests and supporting utilities)
Documentation
gemspec - The gemspec contains your gem's specification by defining several attributes.
And then you can test to see if it works like this:
I then tried to push it to RubyGems but I kept getting this error:
Making a Simple Chrome Extension
Yesterday I set out to make a chrome extension without any idea on where to start so I went to Google and found:
How to Make a Chrome Extension a guide by Adam Pasch of Lifehacker.
This would have been really helpful if it was not out of date, but it is still a good place to start.
He asks us to start with what is the minimum of every chrome extension. A "manifest.json" file that looks like this:
This tells us and the computer the name of the extension, its version number a description of the file, and a browser action.
The problem with this is that the updated chrome wants extensions to be written like this:
This adds a "manifest version" to the code as well as an updated version. I have added the second part to the simple chrome extension by adding an action to the "browser action" part of my extension. That action, "default_popup" points to an HTML file with the stuff that the extension does.
You can only use HTML/CSS, and javascript on this file (not erb), which is annoying. But you can go ahead and put in <p> Hello World! </p> or a youtube video like I did.
and boom you're done.
actually you'll probably want to use an icon so find a picture (28 x 28) and add that to your folder with the icon.png name.
and now you're done.
Validation in Rails
Validation in Rails is the reason people get error messages when they do not put the correct information in on websites. Validations are used to ensure that only valid data is saved into your database. Validations should be saved in your models because controllers should be kept as "skinny" as possible. Rails validations cannot be bypassed by end users unlike some client side databases.
Here is am example:
And these are the errors you would get:
Scaffolding with Fewer Lines
Here's a quick shortcut to scaffold apps faster. I used a Sinatra app as an example. Instead of creating directories and files on separate lines like so:
You can make multiple directories and files on one line:
Today we learned about Box Model in CSS.
All HTML elements can be considered as boxes. In CSS, the term "box model" is used when talking about design and layout.
The CSS box model is essentially a box that wraps around HTML elements, and it consists of: margins, borders, padding, and the actual content.
The box model allows us to place a border around elements and space elements in relation to other elements.
Content represents the content of an element (pictures, words, boxes, videos)
Padding gives space between border and content.
The border frames the content.
Margin separates different elements.
How to make a circular image with CSS
While making my portfolio I thought it would be a cool idea to have my picture be in a circle format instead of the standard square. I didn't know how to do that so I looked it up.
This post assumes you can make an HTML document and connect a stylesheet to it. I had to look that up too.
After you do that you need to insert the div that you want to make a circle.
I named my circle.
Then you go to your CSS sheet and put in a pretty standard 'style':
But that's only going to give you the rectangular picture that we were trying to avoid. To make it a circle you have to add a couple more things:
We just added a border-radius property, which is pretty much all we need to make it a circle. This feature helps you round the corners of your image. To make the image circular we have to use values that are half of the image size values.
Boom. Here's the final product:
Today Codecademy released its first foray into the mobile space, an app-based intro course to coding designed to take less than an hour to complete. I had a..
My friend told me that you can use a mobile version of Ruby to build iPhone apps too. I thought that was cool, so linked is some testimonial from a guy who did it and here is a video from the creator of mobile Ruby http://www.youtube.com/watch?v=HuPOizo6pSE#t=245
The Ruby Code Academy Course
This is what I looked like today when I finally finished the Ruby track on Codeacademy.
I did it! I did it! Happy Thanksgiving weekend everyone. I’m enjoying my time in Maryland with my family and a lot of programming. I’m taking the time to catch up on the pre-work part of the Flatiron school that I did not get a chance to finish. Last night around 3am my hard work was validated as I FINALLY finished the Ruby track on CodeAcademy.com.
Here are my thoughts on the track and CodeAcademy as a whole:
I started using CodeAcademy to teach myself “coding” (whatever that means) around this time last year during my freshman year of college. I finished their web fundamentals track in about a week and came away with a decent understanding of HTML/CSS, but I definitely not program on my own using those languages.
I would try the Ruby and Javascript tracks halfheartedly for a couple hours every few weeks before giving up on them entirely. I just did not understand the syntax and what simple elements meant .Why were the words different colors? Why did not my program fail to run so often? What did #’s and $ even mean?
Questions that seemed impossible to me then now seem so simple: The colors help identify different objects; you have to be careful of capitalization and spacing; #’s help “comment out” code and $ usually just represent a new line in terminal.
This is where I acknowledge my privilege of being at the Flatiron school for the past three weeks. Without the introductory level courses I’m not sure I would have been able to ever finish the track. CodeAcademy, at least the Ruby track, does not feel like a very good place for absolute beginners to learn how to program. There should be more of a focus on introducing concepts to users – perhaps voluntary reading before starting or longer introductory level courses.
With that said, CodeAcademy is a great place for people who kind of know what they are doing to solidify their knowledge. I was able to get a much better understanding of some of the higher-level concepts like inheritance, object-oriented programming and blocks. I even learned about lambdas, something we have yet to go over in class.
I found that as the program went on I was looking at hints a lot less and building what they needed right from the directions instead of looking at syntax. I finished the last, much more difficult, quarter of the course much faster than the first 75%.
I still don’t think I could build most of the things built on my own, but I have a much stronger grasp on the language. I recommend CodeAcademy for anyone ho knows a little bit about Ruby and wants to learn a lot!
We were asked to read this piece by Jordan Moore in class today. It asks a simple question that I would ask myself before the Flatiron school: If you could innovate using magic, how would you do it? It encourages the thinker to start from the impossible because nothing can bound your solution.
Although I feel more empowered since beginning the Flatiron school, I feel slightly feel less creative. Before when I would think about new features for social networks or iphone apps I would do so having no idea how to build them - specifically their difficulty. Now, I catch myself thinking “wow, that would take forever to build” or “I’m not sure if you can do that in Ruby.” I need to work on getting out of that habit so that I can continue to be creative with the freedom of ignorance.
Object Oriented Design Notes
Today we were asked to read a chapter from a Ruby design book by Sandi Metz. Here are some notes and lessons I learned from the chapter.
Summary:
The path to changeable and maintainable object-oriented software begins with classes that have a single responsibility. Classes that do one thing isolate that thing from the rest of your application. This isolation allows change without consequence and reuse without duplication.
Classes are used to create applications that are easy to change.
In Ruby methods are defined as a class.
The code you write should have the following qualities. Code should be:
• Transparent The consequences of change should be obvious in the code that is changing and in distant code relies upon it
• Reasonable The cost of any change should be proportional to the benefits the change achieves
• Usable Existing code should be usable in new and unexpected contexts • Exemplary The code itself should encourage those who change it to perpetuate
these qualities
Code that is Transparent, Reasonable, Usable, and Exemplary (TRUE) not only meets today’s needs but can also be changed to meet the needs of the future. The first step in creating code that is TRUE is to ensure that each class has a single, well-defined responsibility.
A class should do the smallest possible useful thing.
A class that has more than one responsibility is difficult to use.
Methods like classes should have single responsibility
Refactoring
The impact of a single refactoring like this is small, but the cumulative effect of this coding style is huge. Methods that have a single responsibility confer the follow- ing benefits:
Expose previously hidden qualities Refactoring a class so that all of its methods have a single responsibility has a clarifying effect on the class. Even if you do not intend to reorganize the methods into other classes today, having each of them serve a single purpose makes the set of things the class does more obvious.
Avoid the need for comments How many times have you seen a comment that is out of date? Because comments are not executable, they are merely a form of decaying documentation. If a bit of code inside a method needs a comment, extract that bit into a separate method. The new method name serves the same purpose as did the old comment.
Encourage reuse Small methods encourage coding behavior that is healthy for your application. Other programmers will reuse the methods instead of duplicat- ing the code. They will follow the pattern you have established and create small, reusable methods in turn. This coding style propagates itself.
Are easy to move to another class When you get more design information and decide to make changes, small methods are easy to move. You can rearrange behavior without doing a lot of method extraction and refactoring. Small methods lower the barriers to improving your design.