Skip to content

Instantly share code, notes, and snippets.

Elmer Thomas thinkingserious

Block or report user

Report or block thinkingserious

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@thinkingserious
thinkingserious / girl-scout-2019-twilio-function.js
Last active Mar 15, 2019
A Twilio Function using Twilio SendGrid to forward information from an SMS to an Email
View girl-scout-2019-twilio-function.js
exports.handler = function(context, event, callback) {
const sgMail = require('@sendgrid/mail');
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
msgBody = 'We just received a donation from ' + String(event.donation_from);
const msg = {
to: 'outgoing@example.com',
from: 'incoming@example.com',
subject: 'Audrey just received a donation!',
text: msgBody,
html: '<strong>' + msgBody + '</strong>',
@thinkingserious
thinkingserious / girl-scout-2019-pythonista.py
Created Mar 15, 2019
Send a SMS via Twilio and Pythonista on iOS
View girl-scout-2019-pythonista.py
import requests
from requests.auth import HTTPBasicAuth
to_number = 'outgoing_number'
from_number = 'your_twilio_number'
message = 'Thank for your order, we will deliver after our cookie booth sale at around 6pm.'
account_sid = 'your_account_sid'
auth_token = 'your_auth_token'
auth = HTTPBasicAuth(account_sid, auth_token)
url = 'https://api.twilio.com/2010-04-01/Accounts/{}/Messages'.format(account_sid)
values = {
@thinkingserious
thinkingserious / girl-scout-2019-twiml-bin
Created Mar 15, 2019
TwiML bin for generic SMS response
View girl-scout-2019-twiml-bin
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Message><Body>You may place your local, Moreno Valley/Riverside, CA and surrounding areas, order and we will deliver for free (payment due upon delivery): http://www.mvgirlscout.org. Not local to the Inland Empire, California? No problem! Please place your order here to have your cookies shipped or you may donate boxes to deployed miliatry overseas here: https://bit.ly/GirlScoutCookieOnlineOrder
</Body></Message>
</Response>
@thinkingserious
thinkingserious / sample_test.java
Created Oct 18, 2016
Example of Using StopLight.io's Prism Mock Server in a Unit Test
View sample_test.java
@Test
public void test_alerts_get() throws IOException {
SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
request.method = Method.GET;
request.endpoint = "alerts";
Response response = sg.api(request);
@thinkingserious
thinkingserious / java_mock.java
Created Oct 18, 2016
Example of a Mock HTTP Server
View java_mock.java
package com.sendgrid;
import java.io.IOException;
import java.util.HashMap;
public class MockSendGrid extends SendGrid {
Request request;
public MockSendGrid(String apiKey) {
@thinkingserious
thinkingserious / sample_sendgrid_oai.json
Created Oct 18, 2016
Snippit of the SendGrid OAI (Swagger) Definition - /user/webhooks/parse/settings [GET]
View sample_sendgrid_oai.json
"/user/webhooks/parse/settings": {
"get": {
"consumes": [
"application/json"
],
"description": "**This endpoint allows you to retrieve all of your current inbound parse settings.**\n\nThe inbound parse webhook allows you to have incoming emails parsed, extracting some or all of the contnet, and then have that content POSTed by SendGrid to a URL of your choosing. For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Webhooks/parse.html).",
"operationId": "GET_user-webhooks-parse-settings",
"produces": [
"application/json"
],
@thinkingserious
thinkingserious / fluent.rb
Created May 24, 2016
Fluent Interface in Ruby Using Method Chaining and Reflection
View fluent.rb
class Fluent
def initialize(cache: nil)
@cache = cache ? cache : []
end
# Reflection
def method_missing(name, *args, &block)
_(name.to_s)
end
View file1.py
print "Hello World"
@thinkingserious
thinkingserious / Fluent.cs
Last active May 10, 2016
Fluent Interface in C# Using Method Chaining and Reflection
View Fluent.cs
using System;
using System.Dynamic;
namespace Fluent
{
class Client : DynamicObject
{
public string UrlPath;
public Client(string urlPath = null)
@thinkingserious
thinkingserious / fluent.php
Created May 9, 2016
Fluent Interface in PHP Using Method Chaining and Reflection
View fluent.php
<?php
class Fluent {
function __construct($cache) {
$this->cache = ($cache ? $cache : []);
}
// Build the cache, and handle special cases
public function _($name) {
array_push($this->cache, $name);
You can’t perform that action at this time.