I am trying to insert an HTML image to be at the very beginning of this string here.
content = Content.new(type: 'text/plain', value: ('Greetings ' + #lead.name + ',
' 'We thank you for contacting Rocket Elevators to discuss the opportunity to contribute to your project ' + #lead.project_name + '.
A representative from our team will be in touch with you very soon. We look forward to demonstrating the value of our solutions and helping you choose the appropriate product given your requirements.
We’ll Talk soon
The Rocket Team
'))
What should I do? I am using Ruby on rails, and this is for an automated email.
Related
1) Given my email, produced via a mailchimp online editor.
2) I go to my openEdX, log in as administrator of the MOOC. Then got to My MOOC > INSTRUCTOR > EMAILS, in order to send my email. First a test to myself, later to my 2000 mooc students.
3) The email I receive in my inbox is CUT HALF WAY. The bottom part is all missing.
QUESTION : What is going on there ? How to fix this ?
Look into your code for the first paragraph which disapeared. It's likely the buggy part.
For this case, I can see the first disappeared sentence is :
💡 Astuce : Pensez à inviter NudiMooc à suivre votre BLOG
My eyes are catched up by the strange 💡 sign, which is a rare unicode character.
Delete this exotic 💡 sign from your email / html5 code, and it will work again. I tested it by sending to myself. Horray ! The corrected code without the lightbulb was complete !! :D
OpenEdX processing may crash on this string. But because there are some witty security, the previous, valid text is kept.
Has anyone created a simple email report that Jenkins sends out when nightwatch builds fail? or event converted junit reports to email reports?
I would like the following information in a concise report:
Failures
List of code changes
Who was the last people to commit
I don't have a public version, but let me try to offer some assistance how you can combine nodemailer with nightwatch-html-reporter.
I have a working nightwatch located at https://github.com/shane-reaume/nightwatch-bones
You should be able to see where the nightwatch-html-reporter code lives in the globals.js as...
var reporter = new HtmlReporter({
openBrowser: true,
reportsDirectory: __dirname + '/reports/',
themeName: 'default',
reportFilename: os.split(' ').join('-') + '-report.html'
});
Here you are creating an html file. With that you can extract the html for your nodemailer (see https://community.nodemailer.com/).
It seems to be relatively easy if you follow the directions on each, but let me know if you have trouble and I can try to throw something together.
i suggest you to go with the email-extension plugin.
follow the documentation https://wiki.jenkins.io/display/JENKINS/Email-ext+plugin
you can mail the reports as attachements to respective emails sepperating by commas
Using Rails 3.1.1 and Herkou
I have 1.000 products in my app. They all have a very slow controller which is effectively solved by fragment caching. Although the data doesn't change very often, it still needs to expire (which I do by sweeping) periodically, in my case once a week.
Now, after sweeping the cached views I don't want my users to create the new fragments by trying to access the products one after another (takes about 6-8 secs at the first load, 2-3 sec for the cached load). I assume I can do that with some sort of script that will load each Product Page one by one and thus make the server create those fragments.
I can imagine this can be handled in three ways:
Run a script on my local machine that will try to access each url with some sort of get-command - Downside: Not very pretty and will affect visitor stats in a way I would not prefer.
Run the same type script on the server after the sweeper, that will load each Product. How can I do that, in that case?
Using a smart Rails command to do this automatically. Is there such an elegant command?
I made this script and it works. The "product.slug" is because I have friendly_id installed. It will produce url-variables with names such as www.mydomain.com/productabc-123/ which will be read by Nokogiri (Nokogiri gem is needed for this solution).
PLEASE NOTE THAT I SWITCHED FROM FRAGMENT CACHING TO ACTION CACHING IN THIS SOLUTION (as opposed to the question, where I am using fragment caching). The important difference for this is when I check the cache if Rails.cache.exist?('views/www.mydomain.com/' + product.slug). For fragment_caching it should be the fragment name there instead.
require 'nokogiri'
require 'open-uri'
Product.all.each do |product|
url = 'http://www.mydomain.com/' + product.slug
begin
if Rails.cache.exist?('views/www.mydomain.com/' + product.slug)
puts url + " is already in cache"
else
doc = Nokogiri::HTML(open(url))
puts "Reads " + url
# Verifies if the caching worked. Only for trouble shooting
if Rails.cache.exist?('views/www.mydomain.com/' + product.slug)
puts "--->" + url + " is NOW in the cache"
else
puts "--->" + url + " is still not in the cache!"
end
sleep 1
end
rescue
puts 'Normal rescue of ' + url
rescue Timeout::Error
puts 'Timeout rescue of ' + url
puts 'Sleep for 5 sec'
sleep 5
retry
end
end
Create a script that runs as rake task, or better yet a worker, that runs and curls the page. There is no need to include a gem when you can just call curl
`curl -A "CacheRefresher" #{ENV['HOSTNAME']}/api/v1/#{klass.name.underscore.pluralize}/#{id} >/dev/null 2>&1`
I have the following automation code:
lPrintSetup := fWordObject.Application.Dialogs.Item(wdDialogFilePrintSetup);
lPrintSetup.Printer := 'MyPrinter';
lPrintSetup.DoNotSetAsSysDefault := True;
lPrintSetup.Execute;
lPrintSetup := Null;
The Printer property is giving me some problems, sometimes Execute crashes with an EOleException (0x800A1460 (error code 5216): There is a printer error) because of a wrong printername.
I have printer information of all printers in a _PRINTER_INFO_2 record which I obtained by a EnumPrinters API-call. How can I compose the right printername for Word given the information in a _PRINTER_INFO_2 record? It has work with at least Windows 2000, Word 2000 and Citrix.
Some background info:
Our application first filled the Printername with a self constructed printername. This gave problems with Citrix clients, so for Citrix clients we took the _PRINTER_INFO_2.pPortName and deleted the Client:#: part.
This is working for the majority of our customers, but sometimes still the printer error shows up.
What I have tried so far (on Windows XP SP3, Word 2007):
Just take the _PRINTER_INFO_2.pPrinterName. Problem is that when you modify printernames on purpose (renaming 'PDFCreator' to 'HP DESKJET 520 on MYPC') it crashes on the latter (while selecting this printer in Word works).
Composing a printername like this: lPrintSetup.Printer := PRINTER_INFO_2.pPrinterName + ' on ' + PRINTER_INFO_2.pPortname. Seems to work always! But googling around showed that ' on ' is localized, so I'm not sure if that's going to work on non-english Windows versions. Edit: does not work always :(
Another solution I found on the web:
When reading the printername from Word it has the form of "Printername on Ne01:", where Ne01 is ranged from Ne00: to Ne99:. The solution suggested taking the printername and just try to set it while looping from Ne00: to Ne99:. When .Execute doesn't crash, you've got the right one. I'm not very fond of this 'trail and error' method.
I'm not sure if you've tried this, or if its of any use, but you can get a list of all the printers on the system from the Printer.Printers object make sure you add Printers to the Uses clause of your unit.
This should then list the actual names on the system and you may be able to use this information to do what you want.
As stated you can get a list of printer names using the Printer.Printers which is a TStringList with the name of the printer on each item.
This code gives the default printer name
Printer.Printers[Printer.PrinterIndex]
Some minutes ago I learned, that word2k not only wants Printernames like "Printername on Ne01:" it only wants the port (NEnn) uppercase "Printername on NE01:"
I figured it out. Word has the printername in the form of "Printername on NE01:". Ne01: is the printerport as specified in the devices section of win.ini. So now I compose the printername as _PRINTER_INFO_2.pPrinterName + ' on ' + <PrinterPort from win.ini> and set that name for the printer property of the FilePrintSetup dialog.
This is much better than to resort to the trail-and-error method mentioned in my question.
I have a Rails application that has to co-exist with a very old legacy application. The legacy application looks for a cookie that has a value containing a specific string of characters. Unfortunately, the characters in the legacy cookie often contain slashes. The problem I have is that when the Rails application writes the cookie it first does URL-encoding which causes the legacy app to break because the cookie values is incorrect.
I had this working in Rails 1.13.5 by editing the file cookie_performance_fix.rb (Path: ./actionpack-1.13.5/lib/action_controller/cgi_ext/cookie_performance_fix.rb)
In order to get this to work I changed the code as shown:
def to_s
buf = ""
buf << #name << '='
if #value.kind_of?(String)
rails code.
#buf << CGI::escape(#value)
buf << #value
else
#buf << #value.collect{|v| CGI::escape(v) }.join("&")
buf << #value.collect{|v| (v) }.join("&")
end
This actually worked fine until I decided to upgrade Rails to version 2.3.2
In Rails 2.3.2 the cookie_performance_fix.rb file no longer exists. I looked in the same directory and found a file called cookie.rb which I tried modifying in a similar fashion.
def to_s
buf = ''
buf << #name << '='
#buf << (#value.kind_of?(String) ? CGI::escape(#value) : #value.collect{|v| CGI::escape(v) }.join("&"))
buf << (#value.kind_of?(String) ? #value : #value.collect{|v| (v) }.join("&"))
buf << '; domain=' << #domain if #domain
buf << '; path=' << #path if #path
buf << '; expires=' << CGI::rfc1123_date(#expires) if #expires
buf << '; secure' if #secure
buf << '; HttpOnly' if #http_only
buf
end
This unfortunately does not seem to work. The cookie keeps getting URL-encoded in the new Rails 2.3.2. I know that turning off URL-encoding is not the best idea, but I don't have much choice until the legacy application is retired. I unfortunately do not have access to the legacy code to add support for URL-unencoding the cookie so I have to make sure the legacy cookie is written with the correct sequence including the slashes. If anyone can tell me how to turn off URL-encoding in Rails 2.3.2 it would be greatly appreciated.
Thanks.
After doing some digging I have found the answer to my question and I am documenting it here in case it is of use to anyone else.
In order to turn off URL-encoding in Rails 2.3.2 it is necessary to edit the following file: actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/response.rb
Around line 70 the ID and value of the cookie is set. I made the following change to turn of URL-encoding:
cookie = Utils.escape(key) + "=" +
#value.map { |v| Utils.escape v }.join("&") +
value.map { |v| v }.join("&") +
"#{domain}#{path}#{expires}#{secure}#{httponly}"
NOTE: This modification only affects standard cookies - not the cookies used as session data by Rails in version 2.3.2.
DISCLAIMER: I am in no way recommending this modification as a best practice. This modification was only done for the specific reason of handling legacy code requirement that required a cookie to be in a particular format. A better option would even be to modify the legacy code to handle URL-encoding. Unfortunately, that option was closed to me so I was forced to hack around on the underlying Rails code - which is not something I would generally recommend. Of course it should go without saying that making this type of modification runs the risk that the problem will have to be re-addressed every time you upgrade your Rails installation as the underlying code may change. That is actually what happened in my case. And of course there are also probably good reasons (security, standards compliance, etc.) for keeping the URL-encoding if at all possible.
A simple way to do this is using the rack method,
response["set-cookie"]="id_cookie=this cookie will be not escaped"