This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'benchmark' | |
| def sum_range_using_for_loop(min, max) | |
| range = (min..max) | |
| sum = 0 | |
| for n in range | |
| sum = sum + n | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1. Crie duas variáveis com algum texto e imprima elas fazendo concatenação | |
| 2. Crie duas variáveis com algum texto e imprima elas fazendo interpolação | |
| 3. Crie uma variável e com essa variável faça uma tabula do valor da variável. | |
| 4. Cria as variáveis nome, cidade, estado, rua, número da casa e cep. Imprima essas variáveis como se fosse um endereço completo. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # frozen_string_literal: true | |
| Rails.application.config.middleware.insert_before 0, Rack::Cors do | |
| allow do | |
| origins ENV['CORS_ORIGINS'].split(',').map { |origin| origin.strip } | |
| resource '*', | |
| headers: :any, | |
| methods: [:get, :post, :put, :patch, :delete, :options, :head] | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # backup | |
| docker run -v [volume]:/volume --rm loomchild/volume-backup backup - > [backupfile.tar.bz2] | |
| # restore | |
| cat [backupfile.tar.bz2] | docker run -i -v [volume2]:/volume --rm loomchild/volume-backup restore - |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ActiveRecord::Base.establish_connection | |
| ActiveRecord::Base.connection.tables.each do |table| | |
| next if table == 'schema_migrations' | |
| case ActiveRecord::Base.connection.adapter_name.downcase.to_sym | |
| when :mysql2 || :postgresql | |
| ActiveRecord::Base.connection.execute("TRUNCATE #{table}") | |
| when :sqlite | |
| ActiveRecord::Base.connection.execute("DELETE FROM #{table}") | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| My Dotfiles | |
| brew install fzf | |
| brew install xclip | |
| brew install autojump |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "gmSettings": { | |
| "default": { | |
| "items": [ | |
| { | |
| "disposition": "FRIENDLY", | |
| "items": [] | |
| }, | |
| { | |
| "disposition": "NEUTRAL", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| HTTP status code symbols for Rails | |
| Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings. | |
| Status Code Symbol | |
| 1xx Informational | |
| 100 :continue | |
| 101 :switching_protocols | |
| 102 :processing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let params = | |
| [{ | |
| filterType: "transform", | |
| filterId: "myTransform", | |
| padding: 30, | |
| animated: | |
| { | |
| translationY: | |
| { | |
| animType: "sinOscillation", |