See how a minor change to your commit message style can make you a better programmer.
Format: <type>(<scope>): <subject>
<scope> is optional
| http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query | |
| http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails | |
| #payload: [{"kind"=>"person"}] | |
| Segment.where("payload @> ?", [{kind: "person"}].to_json) | |
| #data: {"interest"=>["music", "movies", "programming"]} | |
| Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json) | |
| Segment.where("data #>> '{interest, 1}' = 'movies' ") | |
| Segment.where("jsonb_array_length(data->'interest') > 1") |
| # from_cte_sql = ::Namespace::From.where_clause | |
| # .. | |
| from_table = Arel::Table.new(:from_lane) | |
| to_table = Arel::Table.new(:to_lane) | |
| rates_table = Arel::Table.new(:rates) | |
| rates_table | |
| .join(from_table).on(rates_table[:from_id].eq(from_table[:id])) |
| function calculateDistance(rssi) { | |
| var txPower = -59 //hard coded power value. Usually ranges between -59 to -65 | |
| if (rssi == 0) { | |
| return -1.0; | |
| } | |
| var ratio = rssi*1.0/txPower; | |
| if (ratio < 1.0) { |
Command Line
pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)pry -r ./config/environment.rb - load your rails into a pry sessionDebugger
#SOLID Principles with ruby examples
##SRP - Single responsibility principle A class should have only a single responsibility.
Every class should have a single responsibility, and that responsibility should be entirely encapsulated. All its services should be narrowly aligned with that responsibility, this embrace the high cohesion.
##OCP - Open/closed principle Software entities should be open for extension, but closed for modification.
| function loadJson(callback) { | |
| var XmlHttpRequest = new XMLHttpRequest(); | |
| XmlHttpRequest.overrideMimeType("application/json"); | |
| XmlHttpRequest.open('GET', 'file.json', true); | |
| XmlHttpRequest.onreadystatechange = function () { | |
| if (XmlHttpRequest.readyState == 4 && XmlHttpRequest.status == "200") { | |
| // .open will NOT return a value | |
| // but simply returns undefined in async mode so use a callback | |
| callback(XmlHttpRequest.responseText); | |
| } |
| CREATE TEXT SEARCH CONFIGURATION fr ( COPY = french ); | |
| ALTER TEXT SEARCH CONFIGURATION fr ALTER MAPPING | |
| FOR hword, hword_part, word WITH unaccent, french_stem; | |
| CREATE TEXT SEARCH CONFIGURATION en ( COPY = english ); | |
| ALTER TEXT SEARCH CONFIGURATION en ALTER MAPPING | |
| FOR hword, hword_part, word WITH unaccent, english_stem; | |
| CREATE TEXT SEARCH CONFIGURATION de ( COPY = german ); | |
| ALTER TEXT SEARCH CONFIGURATION de ALTER MAPPING |