ruby

HTML及CSS笔记

风格不统一 提交于 2021-02-08 12:02:54
目标:Front-end Engineer → Full-stack Engineer 浏览器及其内核 HTML 开发工具 sublime 轻量级的ide 1.使用技巧 h${}*6 vsCode 写大项目时使用 1.使用技巧 SEO-搜索引擎优化 <html lang= "en"> < head > < meta charset = " utf-8 " > <!-- charset:编码字符集--> < title > 我是title </ title > < meta content = " 服装 " name = " keywords " > < meta content = " 这是一件你穿了就不想脱的衣服 " name = " description " > </ head > < body > <!-- 告诉搜索引擎爬虫,我们的网站是关于什么内容的 --> <!-- SEO --> </ body > </ html > 路径 1. 网上url <img src="https://xxxxxx.jpg" style="width:200px;"> 2.本地的绝对路径 D:/a/b/test.html D:/a/b/c/123.jpg <img src="D:/a/b/c/123.jpg>" 3. 本地的相对路径 …/来表示上一级目录 D:/a/b/test.html D

Start sidekiq automatically on OSX

坚强是说给别人听的谎言 提交于 2021-02-08 11:52:12
问题 I have coded up a small ruby gem that I use on my laptop to check disk space and other things. I am using a sidekiq worker that runs periodically and emails me status updates. I was wondering how to make a sidekiq worker run automatically after I restart OSX? Is this possible? Cheers 回答1: To run sidekiq you need to run: bundle exec sidekiq . If you want to run this on startup then you can follow these steps: Start Automator.app; Select "Application"; Click "Show library" in the toolbar (if

Microsoft Teams escaping underscores in text

浪尽此生 提交于 2021-02-08 11:38:50
问题 I have following function in ruby to send aws logs to microsoft team channel through webhook. Some text contains underscore signs like connection_web but appears like connectionweb in MS teams. How to get the exact output ? require 'json' require 'net/https' require 'uri' require 'base64' require 'zlib' require 'stringio' def lambda_handler(event:, context:) log_event = JSON.parse(decode_and_decompress(event["awslogs"]["data"])) response = speak(messages_from_blob(log_event)) puts response

Microsoft Teams escaping underscores in text

北战南征 提交于 2021-02-08 11:38:43
问题 I have following function in ruby to send aws logs to microsoft team channel through webhook. Some text contains underscore signs like connection_web but appears like connectionweb in MS teams. How to get the exact output ? require 'json' require 'net/https' require 'uri' require 'base64' require 'zlib' require 'stringio' def lambda_handler(event:, context:) log_event = JSON.parse(decode_and_decompress(event["awslogs"]["data"])) response = speak(messages_from_blob(log_event)) puts response

Finding the intersection of two lines

孤人 提交于 2021-02-08 11:20:34
问题 I have two lines: y = -1/3x + 4 y = 3x + 85 The intersection is at [24.3, 12.1] . I have a set of coordinates prepared: points = [[1, 3], [4, 8], [25, 10], ... ] #y = -1/3x + b m_regr = -1/3 b_regr = 4 m_perp = 3 #(1 / m_regr * -1) distances = [] points.each do |pair| x1 = pair.first y2 = pair.last x2 = ((b_perp - b_regr / (m_regr - m_perp)) y2 = ((m_regr * b_perp) / (m_perp * b_regr))/(m_regr - m_perp) distance = Math.hypot((y2 - y1), (x2 - x1)) distances << distance end Is there a gem or

in iOS 11 the keyboard autocorrect creates invalid UTF8

我是研究僧i 提交于 2021-02-08 11:15:42
问题 Our app accepts user text input which we then save to a server-side database. In iOS 11 when you enter two "-" characters in a row they are automatically combined into an emdash (—). When you enter three "-" characters in a row you end up with an emdash + a half emdash which has an invalid terminator. This is causing issues for my rails server which cannot parse this string because it is invalid. The string looks like this: \xE2\x80\x94\x00 回答1: 'Smart dashes' as it is called, is the process

in iOS 11 the keyboard autocorrect creates invalid UTF8

随声附和 提交于 2021-02-08 11:14:11
问题 Our app accepts user text input which we then save to a server-side database. In iOS 11 when you enter two "-" characters in a row they are automatically combined into an emdash (—). When you enter three "-" characters in a row you end up with an emdash + a half emdash which has an invalid terminator. This is causing issues for my rails server which cannot parse this string because it is invalid. The string looks like this: \xE2\x80\x94\x00 回答1: 'Smart dashes' as it is called, is the process

Change the default file download path for Edge using selenium

可紊 提交于 2021-02-08 10:46:28
问题 I was using selenium-ruby for automating browser application. I want to simulate file download scenario. When I want to execute for chrome I had a method named "download_path", its value can be changed at run-time and when download file it will be saved at my destination path. But, when I execute the same code for edge there is no method support for "download_path" in edge. Is there any way to set my default download location at runtime? Chrome Code: @browser = Selenium::WebDriver.for :chrome

Ruby - local variable gets modified when changing instance variable

半城伤御伤魂 提交于 2021-02-08 10:44:23
问题 temp gets @board.dup , and @board array is modified. However, temp gets modified as well! I have tried reading all the related documentations but still couldn't figure out an explanation. class Test def initialize @board = [[1,2],[3,4], [5,6]] end def modify temp = @board.dup #Also tried .clone print 'temp: ';p temp print '@board: ';p @board @board.each do |x| x << "x" end print "\ntemp: ";p temp print '@board: ';p @board end end x = Test.new x.modify Output: temp: [[1, 2], [3, 4], [5, 6]]

Ruby - local variable gets modified when changing instance variable

故事扮演 提交于 2021-02-08 10:43:16
问题 temp gets @board.dup , and @board array is modified. However, temp gets modified as well! I have tried reading all the related documentations but still couldn't figure out an explanation. class Test def initialize @board = [[1,2],[3,4], [5,6]] end def modify temp = @board.dup #Also tried .clone print 'temp: ';p temp print '@board: ';p @board @board.each do |x| x << "x" end print "\ntemp: ";p temp print '@board: ';p @board end end x = Test.new x.modify Output: temp: [[1, 2], [3, 4], [5, 6]]