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
| module Streaks | |
| class Drives | |
| MINIMUM_RATING_FOR_STREAK = 5 | |
| ACTIVE_STREAK_MINIMUM_AMOUNT = 3 | |
| def initialize user | |
| @user = user | |
| 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
| # Create a Secret Key for Rails | |
| # | |
| # You can generate a secure one through the Greenlight docker image | |
| # with the command. | |
| # | |
| # docker run --rm bigbluebutton/greenlight:v2 bundle exec rake secret | |
| # | |
| SECRET_KEY_BASE= | |
| # The endpoint and secret for your BigBlueButton server. |
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 | |
| # BigBlueButton open source conferencing system - http://www.bigbluebutton.org/. | |
| # | |
| # Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below). | |
| # | |
| # This program is free software; you can redistribute it and/or modify it under the | |
| # terms of the GNU Lesser General Public License as published by the Free Software | |
| # Foundation; either version 3.0 of the License, or (at your option) any later | |
| # version. |
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
| /* | |
| * Handling Errors using async/await | |
| * Has to be used inside an async function | |
| */ | |
| try { | |
| const response = await axios.get('https://your.site/api/v1/bla/ble/bli'); | |
| // Success 🎉 | |
| console.log(response); | |
| } catch (error) { | |
| // Error 😨 |
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
| # routes.rb | |
| match 'ads/:id/present/*path.:format', :to => 'ads#present' | |
| # ads_controller.rb | |
| def present | |
| @ad = Ad.find(params[:id]) | |
| path = "#{params[:path]}.#{params[:format]}" | |
| send_data(@ad.get_file(path), :filename => path, :disposition => 'inline') | |
| 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
| #!/usr/bin/env ruby | |
| # example: ruby task_p2.rb | |
| require 'json' | |
| require 'yaml' | |
| def set(hash, path, val) | |
| parts = path.split('.') | |
| scope = hash |
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
| #!/usr/bin/env ruby | |
| # example: ruby task_p1_t2_v2.rb 'To be or not to be -that is the question' 5 | |
| require 'ostruct' | |
| v1, v2 = ARGV | |
| input_str = v1 | |
| n = v2.to_i | |
| input_words = input_str.split(/\s+/) |
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
| #!/usr/bin/env ruby | |
| # example: ruby task_p1_t2_v1.rb 'To be or not to be that is the question' 5 | |
| v1, v2 = ARGV | |
| puts v1.scan(/.{1,#{v2}}\b|.{1,#{v2}}/).each(&:lstrip!).join("\n") |
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
| #!/usr/bin/env ruby | |
| # example: ruby task_p1_t1.rb 'abcdab987612' | |
| require 'ostruct' | |
| input_str = ARGV[0] | |
| input_chars = input_str.chars | |
| first_char = input_chars.shift | |
| initial_state = OpenStruct.new( |
NewerOlder