ruby

Making ruby calculator run continuously

烈酒焚心 提交于 2021-01-29 02:18:05
问题 I have made a simple calculator in ruby. However after running once the program stops and has to be re-run. I tried the following but it ended in an infinite loop. How can I write this so that it will run until the users tells it to quit? puts "Please enter two digits separated by operation you would like to calculate:" input = gets.chomp.split(' ') while input != nil if input[1] == "+" puts input[0].to_i + input[2].to_i elsif input[1] == "-" puts input[0].to_i - input[2].to_i elsif input[1]

Making ruby calculator run continuously

橙三吉。 提交于 2021-01-29 02:16:09
问题 I have made a simple calculator in ruby. However after running once the program stops and has to be re-run. I tried the following but it ended in an infinite loop. How can I write this so that it will run until the users tells it to quit? puts "Please enter two digits separated by operation you would like to calculate:" input = gets.chomp.split(' ') while input != nil if input[1] == "+" puts input[0].to_i + input[2].to_i elsif input[1] == "-" puts input[0].to_i - input[2].to_i elsif input[1]

Don't have access to Heroku app

孤者浪人 提交于 2021-01-29 00:29:57
问题 I have a mystery app in Heroku. It's called weird-app-5536 When I try to push my code to Heroku I get this message: Your account my_email@geemail.com does not have access to weird-app-5536. ! ! SSH Key Fingerprint: ************************************************* fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. When I try... heroku apps I get a list of my apps, but it does not include the mystery app, weird-app-5536.

Don't have access to Heroku app

筅森魡賤 提交于 2021-01-29 00:29:05
问题 I have a mystery app in Heroku. It's called weird-app-5536 When I try to push my code to Heroku I get this message: Your account my_email@geemail.com does not have access to weird-app-5536. ! ! SSH Key Fingerprint: ************************************************* fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. When I try... heroku apps I get a list of my apps, but it does not include the mystery app, weird-app-5536.

My bundler command is failing to load in my Sinatra app deployed in Heroku and thus causes it to crash

 ̄綄美尐妖づ 提交于 2021-01-28 22:20:09
问题 I am trying to successfully deploy an extremely rudimentary Sinatra app to Heroku. I am able to run this app locally. The ruby code itself is incredibly simple: require 'sinatra' get '/' do 'Hello World!' end I added a proper Gemfile: source 'https://rubygems.org' gem 'sinatra' gem 'rack' As well as a configuration file: require './hello_app' run SinatraApp This code builds successfully on Heroku: -----> Ruby app detected -----> Installing bundler 2.1.4 -----> Removing BUNDLED WITH version in

Conditional class in slim with 3 conditions

六月ゝ 毕业季﹏ 提交于 2021-01-28 22:17:43
问题 I would like to write conditional class in slim but I only know how to do it with 2 conditions, like : div class=(index == 0 ? 'class1' : 'class1 class3') How to do it with three conditions? - if index == 0 .class1 - elsif index == -1 .class2.class3 - else .class1.class3 回答1: div class=(if index == 0 then 'class1' elsif index == -1 then 'class2 class3' else '.class1 class3' end) 来源: https://stackoverflow.com/questions/40591084/conditional-class-in-slim-with-3-conditions

JS | 教练,我想做习题4

坚强是说给别人听的谎言 提交于 2021-01-28 22:10:12
🚀 前言 大家好呀,我是毛小悠,可以叫我二毛,在家中排行老二,是一名前端开发工程师。 本系列文章旨在通过练习来提高JavaScript的能力,一起愉快的做题吧。😀😀😀 以下每道题,二毛我都有尝试做一遍。建议限时训练,比如限定为半小时,如果半小时内想不出来,可以结合文章末尾的参考答案来思考。 可以在下方评论区留言或者加我的微信:code_maomao。期待你的到来。 求关注求点赞 👍~~~😘😘😘 📖 题目1:连续重复次数最长的字符 对于给定的字符串s找到连续重复次数最长的字符c(或C),然后返回: [c, l] 其中l(或L)是重复的长度。如果有两个或更多个相同的字符l,则按出现的顺序返回第一个。 对于空字符串返回: ["", 0] 祝您编码愉快!:) 习题代码: function longestRepetition(s) { } 📖 题目2:Detect Pangram 七巧板是包含至少一个字母的每个字母的句子。 例如,句子“快速的棕色狐狸跳过懒惰的狗” "The quick brown fox jumps over the lazy dog"是一个连字符,因为它至少一次使用字母A-Z(大小写无关)。 给定一个字符串,检测它是否是一个七巧板。 如果是,则返回True,否则返回False。 忽略数字和标点符号。 也就是说a-z每个字母都使用过至少一次,就返回true。

How to execute linux command from rakefile?

依然范特西╮ 提交于 2021-01-28 21:29:31
问题 I have the following command: ps -ef | awk '{if( $8~"java" || $8~"ruby" || $8~"god"){printf("Killing : %s \n",$2);{system("kill -9 "$2)};}};' How do i excute this linux command from rakeFile. I tried: task :kill_process do `ps -ef | awk '{if( $8~"java" || $8~"ruby" || $8~"god"){printf("Killing : %s \n",$2);{system("kill -9 "$2)};}};'` end But on executing it's giving error: awk: cmd. line:1: {if( $8~"java" || $8~"glassfish" || $8~"ruby" || $8~"god" || $8~"couch"){printf("Killing : %s awk: cmd

No Method Error - Ruby Calculator

蹲街弑〆低调 提交于 2021-01-28 19:55:54
问题 Based on the Ruby Monk Calculator exercise, I was trying to build a simple calculator that can add and subtract: class Calculator def add(a,b) a + b end def subtract(a,b) a - b end end puts "input first integer" a = gets.chomp.to_i puts "input second integer" b = gets.chomp.to_i puts "add or subtract?" response = gets.chomp.downcase if response == "add" Calculator.add(a,b) else response == "subtract" Calculator.subtract(a,b) end When I run the code, I keep getting the 'NoMethodError' - the

Add notification to RoR messaging inbox system

痞子三分冷 提交于 2021-01-28 19:08:14
问题 I have a rails app with intern messaging system. User can send message to other user. Example : User 1 send message User 2 can respond viceversa. All works perfectly. But I want to upgrade this system with notfications functionnality. I want to type of notifications : 1) On navbar 2) By mail Problem : I dont know how i can do this. Can you help me ? Conversations table class CreateConversations < ActiveRecord::Migration def change create_table :conversations do |t| t.integer :sender_id t