Email from = new Email("test@example.com"); String subject = "Sending with SendGrid is Fun"; Email to = new Email("test@example.com"); Content content = new Content("text/plain", "and easy to do anywhere, even with Java"); Mail mail = new Mail(from, subject, to, content); SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY")); Request request = new Request(); try { request.setMethod(Method.POST); request.setEndpoint("mail/send"); request.setBody(mail.build()); Response response = sg.api(request); System.out.println(response.getStatusCode()); System.out.println(response.getBody()); System.out.println(response.getHeaders()); } catch (IOException ex) { throw ex; }
Monthly Archives: January 2019
SQL replace newline
SELECT REPLACE(REPLACE(@str, CHAR(13), ''), CHAR(10), '')
Python CSV import.
A good starting point
Print Python List
mylist = ['x', 3, 'b']
print '[%s]' % ', '.join(map(str, mylist))
Synthesize text to audio Google Synthesis
Python Records. Connection Pool
Important Considerations:
- Setup pool class to sqlalchemy.pool.NullPool when you create database so we don't allow pooling and only one connection is created, and it is correctly deleted when we call close method.
- Connection needs to be closed at the end of each call. Close it in finally block.