This is a tweet from someone
Don't abstract too early. Duplication is far easier to deal with than the wrong abstraction. @sandimetz (OO version of YAGNI) #railsconf
Abstractions should be used because there is a pain that needs solving, whether that be because you're talking to third party code, or slow remote calls that need hiding during testing or because there is complexity that needs hiding. Putting abstractions in before we feel any of this pain just means more code to wade through when trying to get stuff done - no thanks.This goes against current-popular-thinking as of today.
rails s -p 10524
Clicking the button did run our JavaScript code, which we can verify by seeing that the request began. However, it also triggered a form submission since that’s the browser’s default behavior when buttons inside forms are clicked.
...
Putting a leash on the browser’s default behavior
There are a couple ways to tame the browser’s form submission mechanism and make the button work asynchronously, as expected.
- return false – In almost all cases, an event handler function returning false causes the browser to cancel any subsequent behaviors that the event would normally have triggered (like submitting a form). Using return false works, but you need to be careful about where you place it since the return statement can abort your code early and it can have unintended side-effects.
Since
- preventDefault() – The browser sends an event parameters to handlers, which details information about the action that triggered the handler. That event object also exposes a method that prevents the browser’s default reaction to that event:
preventDefault(). For click handlers on submit buttons inside forms, that includes preventing the form submission.return falsedoes have the issue of sometimes breaking other code and plugins when it stops propagation, I usepreventDefault()by… default.
The Problem
RVM does its own installation magic, but in Ubuntu's case it doesn't always install to the right Bash startup file. You probably don't actually have RVM running properly; even though it's sort of installed.The Fix
You need to make sure the following two lines are at the BOTTOM of your ~/.bashrc file.[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" export PATH=$PATH:$HOME/.rvm/binThen restart your terminal emulator or log back in. Note that sourcing ~/.bashrc has been known not to work in some cases, so this step will save your sanity.RVM should now be working properly. The last step is to set your default Ruby.rvm --default use 1.9.2Important Edit
As I've just been reminded, RVM breaks Ubuntu login shells by installing ~/.bash_login, which overrides your Ubuntu ~/.profile in login shells. Move the code over to your ~/.bashrc if you haven't already done so, then remove or rename ~/.bash_login.
Kelman argues that eventually IT departments will recognize the power of Ruby and use it.
When they do, Salesforce.com will have the most business-friendly way to use Ruby, one that delivers Ruby as a Platform-as-a-Service, but which is connected to a mature ecosystem of business software components like Chatter, Force.com, and Database.com....Heroku + Chatter + Force.com + Database.com
gem "foo", :path => "/path/to/foo"
## Usage ##Github Color Theme:
Open any directory of your GIT working copy in Sublime Text 2.
* Press `Ctrl + Shift + P` and select `Github: Open File` or just press `Ctrl + Shift + ^` to open currently edited file in Github.
* Press `Ctrl + Shift + P` and select `Github: Blame` to open blame for currently edited file in Github.
"highlight_modified_tabs": true,"fade_fold_buttons": false,"bold_folder_labels": true,View → Side Bar → Show Open FilesIf you use git, you've used the commandgit add. But do you know about git add's "patch mode" usinggit add -p?Patch mode allows you to stage parts of a changed file, instead of the entire file. This allows you to make concise, well-crafted commits that make for an easier to read history.
options.chartArea = { left: '8%', top: '8%', width: "70%", height: "70%" };https://developers.google.com/chart/interactive/docs/gallery/piechart#Configuration_Options
We would want to do this in Dev environment.config.assets.enabled = false
evalshould best be avoided in real scenarios. Ruby has saner tools (#define_method,#send) in its meta-programming repertoire that you can use to achieve eval-like cleverness.
Ninject or such DI container will do that...
A reverse-proxy is a "backwards" proxy-cache server; it's a proxy server that, rather than allowing internal users to access the Internet, lets Internet users indirectly access certain internal servers.http://serverfault.com/questions/8654/what-is-a-reverse-proxy
A reverse proxy, also known as an "inbound" proxy is a server that receives requests from the Internet and forwards (proxies) them to a small set of servers, usually located on an internal network and not directly accessible from outside. It's "reverse", because a traditional ("outbound") proxy receives requests from a small set of clients on an internal network and forwards them to the Internet.http://www.jscape.com/blog/bid/87783/Forward-Proxy-vs-Reverse-Proxy
git push origin --delete branchName
require 'benchmark'
Benchmark.bm do |x|
x.report { 50000.times { a = 'a@b.c'.split('@')[0] } }
x.report { 50000.times { a = 'a@b.c'[/[^@]+/] } }
end