ruby

Unable to push a custom gem to heroku master

南楼画角 提交于 2021-02-04 21:37:18
问题 I have created a simple custom gem in 'gemz' folder and configured in gemfile ('checkpercentage', '~>0.1.0') and it works fine in my application but can't deploy it to heroku. I'm getting the following error when trying to push my updates into my master branch at Heroku. my Ruby version: ruby 2.1.1p76 (2014-02-24 revision 45161) [i686-linux] Error: nci@nci-VirtualBox:~/Zacchi/kuizu$ git push heroku master remote: Compressing source files... done. remote: Building source: remote: remote: -----

Building regex to match 2 words only

为君一笑 提交于 2021-02-04 21:29:27
问题 I'm trying to make regexp that match only 2 words and a single pace between. No special symbols, only [a-zA-Z] space [a-zA-z] . Foo Bar # Match (two words and one space only) Foo # Mismatch (only one word) Foo Bar # Mismatch (2 spaces) Foo Bar Baz # Mismatch (3 words) 回答1: You want ^[a-zA-Z]+\s[a-zA-Z]+$ ^ # Matches the start of the string + # quantifier mean one or more of the previous character class \s # matches whitespace characters $ # Matches the end of the string The anchors ^ and $

Building regex to match 2 words only

北城余情 提交于 2021-02-04 21:28:39
问题 I'm trying to make regexp that match only 2 words and a single pace between. No special symbols, only [a-zA-Z] space [a-zA-z] . Foo Bar # Match (two words and one space only) Foo # Mismatch (only one word) Foo Bar # Mismatch (2 spaces) Foo Bar Baz # Mismatch (3 words) 回答1: You want ^[a-zA-Z]+\s[a-zA-Z]+$ ^ # Matches the start of the string + # quantifier mean one or more of the previous character class \s # matches whitespace characters $ # Matches the end of the string The anchors ^ and $

Algorithm to print all valid combations of n pairs of parenthesis

旧巷老猫 提交于 2021-02-04 16:17:32
问题 I'm working on the problem stated in the question statement. I know my solution is correct (ran the program) but I'm curious as to whether or not I'm analyzing my code (below) correctly. def parens(num) return ["()"] if num == 1 paren_arr = [] parens(num-1).each do |paren| paren_arr << paren + "()" unless "()#{paren}" == "#{paren}()" paren_arr << "()#{paren}" paren_arr << "(#{paren})" end paren_arr end parens(3), as an example, will output the following: ["()()()", "(()())", "(())()", "()(())

Another way instead of escaping regex patterns?

我的梦境 提交于 2021-02-04 14:25:38
问题 Usually when my regex patterns look like this: http://www.microsoft.com/ Then i have to escape it like this: string.match(/http:\/\/www\.microsoft\.com\//) Is there another way instead of escaping it like that? I want to be able to just use it like this http://www.microsoft.com, cause I don't want to escape all the special characters in all my patterns. 回答1: Regexp.new(Regexp.quote('http://www.microsoft.com/')) Regexp.quote simply escapes any characters that have special regexp meaning; it

Another way instead of escaping regex patterns?

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-04 14:25:07
问题 Usually when my regex patterns look like this: http://www.microsoft.com/ Then i have to escape it like this: string.match(/http:\/\/www\.microsoft\.com\//) Is there another way instead of escaping it like that? I want to be able to just use it like this http://www.microsoft.com, cause I don't want to escape all the special characters in all my patterns. 回答1: Regexp.new(Regexp.quote('http://www.microsoft.com/')) Regexp.quote simply escapes any characters that have special regexp meaning; it

In what contexts do programming languages make real use of an Infinity value?

旧巷老猫 提交于 2021-02-04 10:17:20
问题 So in Ruby there is a trick to specify infinity: 1.0/0 => Infinity I believe in Python you can do something like this float('inf') These are just examples though, I'm sure most languages have infinity in some capacity. When would you actually use this construct in the real world? Why would using it in a range be better than just using a boolean expression? For instance (0..1.0/0).include?(number) == (number >= 0) # True for all values of number => true To summarize, what I'm looking for is a

How to list ruby production only dependencies using Gemfile.lock and LockfileParser class

纵饮孤独 提交于 2021-02-04 08:27:38
问题 I have a tool that analyze some ruby projects having Gemfile and Gemfile.lock files. This tool given in input the path where ruby project is, list all its dependencies. My problem is that I only need to print production dependencies excluding development and test. Today I find out that my code does not exclude them and I do not know how to modify it for my purpose. How I can remove development and test dependencies from the list? Here a simplified version of the ruby code I use to list

编写Postgres扩展之二:类型和运算符

岁酱吖の 提交于 2021-02-02 06:57:45
原文: http://big-elephants.com/2015-10/writing-postgres-extensions-part-ii/ 编译:Tacey Wong 在上一篇关于编写Postgres Extensions的文章中,我们介绍了扩展PostgresQL的基础知识。现在是有趣的部分来了——开发我们自己的类型。 一个小小的免责声明 最好不要急于复制和粘贴本文中的代码。文中的代码有一些严重的bug,这些bug是为了说明解释的目的而故意留下的。如果您正在寻找可用于生产的 base36 类型定义,请查看 这里 。 复习一下base36 我们需要的是一个用于存储和检索 base36数字 的base36数据类型的可靠实现。我们已经为扩展创建了基本框架,包括base36、controler和Makefile,您可以在专门用于本系列博客文章的GitHub repo中找到它们。您可以查看我们在第1部分中得到的结果,本文中的代码可以在第2部分分支中找到。 文件名:base36.control # base36 extension comment = 'base36 datatype' default_version = '0.0.1' relocatable = true 文件名:Makefile EXTENSION = base36 # 扩展名称 DATA = base36--0

Google 是如何设计 Ruby Serverless Runtime 的?

孤街浪徒 提交于 2021-02-01 10:50:28
Google 在设计 Ruby Serverless Runtime 时面临的一些设计问题,做出的决策以及为什么做出这些决策。 本文来源: ServerlessLife 公众号 原文:https://daniel-azuma.com/blog/2021/01/20/designing-a-ruby-serverless-runtime 作者:Daniel Azuma(Google) 译者:donghui 2021年1月中旬,Google 宣布了 Cloud Functions 的 Ruby 运行时公测。Cloud Functions 是 Google 的函数即服务(Faas)平台。在过去的一年时间里,Google Cloud Functions 对 Ruby 语言的支持已经落后于其他语言,但是我们现在已经赶上了,我想我会分享该产品背后的一些设计过程。 本文不是传统的设计文档。我不会逐步介绍设计本身。相反,我想讨论我们面临的一些设计问题,做出的决策以及为什么做出这些决策。因为这是一个关于如何将 Ruby 约定与公共云约定融合的有趣练习。我认为,我们做出的一些权衡,代表着整个 Ruby 社区随着行业的发展而面临的挑战。 一种实现 Ruby Serverless 化的方式 为 Serverless 产品提供 Ruby 支持比您预期的要复杂得多。从最基本的角度来看,语言运行时只是 Ruby