Skip to content

Instantly share code, notes, and snippets.

View thinkingserious's full-sized avatar

Elmer Thomas thinkingserious

View GitHub Profile
@thinkingserious
thinkingserious / girl-scout-2019-twilio-function.js
Last active March 15, 2019 17:25
A Twilio Function using Twilio SendGrid to forward information from an SMS to an Email
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 March 15, 2019 16:54
Send a SMS via Twilio and Pythonista on iOS
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 March 15, 2019 16:46
TwiML bin for generic SMS response
<?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 October 18, 2016 19:37
Example of Using StopLight.io's Prism Mock Server in a Unit Test
@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 October 18, 2016 19:34
Example of a Mock HTTP Server
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 October 18, 2016 19:30
Snippit of the SendGrid OAI (Swagger) Definition - /user/webhooks/parse/settings [GET]
"/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 02:28
Fluent Interface in Ruby Using Method Chaining and Reflection
class Fluent
def initialize(cache: nil)
@cache = cache ? cache : []
end
# Reflection
def method_missing(name, *args, &block)
_(name.to_s)
end
@thinkingserious
thinkingserious / file1.py
Created May 11, 2016 22:29
Multi File Gist
print "Hello World"
@thinkingserious
thinkingserious / Fluent.cs
Last active May 10, 2016 16:26
Fluent Interface in C# Using Method Chaining and Reflection
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 16:43
Fluent Interface in PHP Using Method Chaining and Reflection
<?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);