Create a drag and droppable List in Rails
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
| string = "1-4 m: mrfmmbjxr | |
| 5-16 b: bbbbhbbbbpbxbbbcb | |
| 7-8 x: qxrxmxccxxx | |
| 9-11 k: kkkkkkktmkhk | |
| 8-12 g: sgwvdxzhkvndv | |
| 6-9 v: zvmvvmvvvd | |
| 8-19 f: ffffsplmfflffhtfrfj | |
| 5-16 p: pppppppppspppjpcp | |
| 2-3 w: wwmw | |
| 7-19 j: jjjjjjjjjjjjjjjjjjvj |
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
| array = %w( | |
| 1768 | |
| 1847 | |
| 1905 | |
| 1713 | |
| 1826 | |
| 1846 | |
| 1824 | |
| 1976 | |
| 1687 |
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
| const previewImageOnFileSelect = () => { | |
| // we select the photo input | |
| const input = document.getElementById('photo-input'); | |
| if (input) { | |
| // we add a listener to know when a new picture is uploaded | |
| input.addEventListener('change', () => { | |
| // we call the displayPreview function (who retrieve the image url and display it) | |
| displayPreview(input); | |
| }) | |
| } |
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
| numbers = [1, 2, 5, 8, 10, 13] | |
| enum.filter_map { |i| i * 2 if i.even? } | |
| # => [4, 16, 20] |
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
| class BaseRepo | |
| def initialize(csv_file) | |
| @csv_file = csv_file | |
| @elements = [] | |
| @next_id = 1 | |
| load_csv if File.exist?(@csv_file) | |
| end | |
| def create(element) | |
| element.id = @next_id |
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
| class Patient | |
| attr_accessor :room, :id | |
| def initialize(attributes = {}) | |
| @id = attributes[:id] | |
| @name = attributes[:name] | |
| @cured = attributes[:cured] || false | |
| end | |
| 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
| require_relative "task" | |
| require_relative "view" | |
| class Controller | |
| def initialize(repository) | |
| @repository = repository | |
| @view = View.new | |
| end | |
| def add_task |
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
| something.gsub(/src=(?<url>[^\s]+)/, 'src="" data-src=\k<url> class="lozad"') | |
| # here \k<something> where something is the name of the group in your regex. |
gem install gist
Please log in with gist --login. (GitHub now requires credentials to gist https://bit.ly/2GBBxKw)
gist --login
https://github.com/login/device
Success! https://github.com/settings/connections/applications/4f7ec0d4eab38e74384e