Skip to content

Instantly share code, notes, and snippets.

View martyndavies's full-sized avatar

Martyn Davies martyndavies

View GitHub Profile
// Bring in the Tessel basics
var tessel = require('tessel');
// Needle for HTTP requests
var needle = require('needle');
// There's a button on the Tessel, when it is pressed, send an email!
tessel.button.on('release', function(time){
// Bundle up the elements we need for our email and verification
var data = "api_user=sendgrid-api-user&api_key=sendgrid-api-keyn&[email protected]&[email protected]&subject=Hi from your Tessel!&text=This was sent from a Tessel";
// Send it all to SendGrid and handle the responses
@martyndavies
martyndavies / set-up-tessel
Last active August 29, 2015 14:03
Set up Tessel and connect to WIFI
$ npm install -g tessel
$ tessel update
$ tessel wifi -n MyWifi -p myw1f1pass -s wpa2
$ heroku create
// wait for creation to happen
$ heroku addons:add scheduler
$ heroku addons:open scheduler
#!/bin/env node
// Requirements, SendGrid and Request (http.request will also work and you can drop Request)
var sendgrid = require('sendgrid')(process.env.sendgrid_username, process.env.sendgrid_api_key);
var request = require('request');
var applications = [];
var html = "";
// Some settings, not always necessary
var settings = {
<img alt="My Image" src="data:image/jpeg;base64,/9j/4S/+RXhpZgAATU0AKgAAAAgACAESAAMAENkDZ5u8/61a+X...more encoding" />
<html>
<body>
<img src="cid:myimagecid"/>
</body>
</html>
var params = {
smtpapi: new sengrid.SmtpapiHeaders(),
... //some vars removed here!
files: [
{
filename: 'image.jpg',
contentType: 'image/jpeg',
cid: 'myimagecid',
content: ('yourbase64encodedimageasastringcangohere' | Buffer)
}
$(document).ready(function(){
// Initialize Parse with your Parse application & javascript keys
Parse.initialize("your_parse_app_key", "your_parse_javascript_key");
// Setup the form to watch for the submit event
$('#myForm').submit(function(e){
e.preventDefault();
// Grab the elements from the form to make up
<html>
<head>
<title>Contact Form</title>
<!-- We need the hosted versions of jQuery and the Parse library -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://www.parsecdn.com/js/parse-1.2.16.min.js"></script>
<script src="/js/emailer.js"></script>
<style type="text/css">
Parse.Cloud.define("sendEmail", function(request, response) {
var sendgrid = require("sendgrid");
sendgrid.initialize("your_sendgrid_username", "your_sendgrid_password");
var name = request.params.name;
var email = request.params.email;
var message = request.params.message;
sendgrid.sendEmail({
to: "[email protected]",