The following guide will show you how to deploy a simple microservice written in JavaScript using 𝚫 now.
It uses Open Source tools that are widely available, tested and understood:
- Node.JS
- NPM
- Express
| /********************************************************************* | |
| Adafruit invests time and resources providing this open source code, | |
| please support Adafruit and open-source hardware by purchasing | |
| products from Adafruit! | |
| MIT license, check LICENSE for more information | |
| Copyright (c) 2019 Ha Thach for Adafruit Industries | |
| All text above, and the splash screen below must be included in | |
| any redistribution | |
| *********************************************************************/ |
| /* | |
| * This sketch illustrates how to set a timer on an SAMD21 based board in Arduino (Feather M0, Arduino Zero should work) | |
| * It should generate a 1Hz square wave as it is (thanks richdrich for the suggestion) | |
| * Some more info about Timer Counter works can be found in this article: | |
| * http://www.lucadavidian.com/2017/08/08/arduino-m0-pro-il-sistema-di-clock/ | |
| * and in the datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/SAM_D21_DA1_Family_DataSheet_DS40001882F.pdf | |
| */ | |
| uint32_t sampleRate = 1000; //sample rate in milliseconds, determines how often TC5_Handler is called |
| #!/usr/bin/env python | |
| """ | |
| Twitter's API doesn't allow you to get replies to a particular tweet. Strange | |
| but true. But you can use Twitter's Search API to search for tweets that are | |
| directed at a particular user, and then search through the results to see if | |
| any are replies to a given tweet. You probably are also interested in the | |
| replies to any replies as well, so the process is recursive. The big caveat | |
| here is that the search API only returns results for the last 7 days. So |
| #!/usr/bin/env python | |
| """ | |
| If you use webrecorder.io to archive a Twitter search result and then download | |
| the WARC file you can use this script to read through the WARC file looking | |
| for tweet identifiers to hydrate. | |
| You'll need to install the [warc] module for the script to work. After that you should be able to: | |
| ./tweet-ids.py file.warc.gz > ids.txt |
| var request = require('request'); | |
| var async = require('async'); | |
| // TODO: This could be in its own package. | |
| function postImage(opts, allDone) { | |
| var twit; | |
| var dryRun; | |
| var imgurl; | |
| var altText; | |
| var caption; |
The following guide will show you how to deploy a simple microservice written in JavaScript using 𝚫 now.
It uses Open Source tools that are widely available, tested and understood:
| var Twit = require('twit') | |
| var moment = require('moment'); | |
| var fs = require('fs'); | |
| var T = new Twit({ | |
| consumer_key: '...', | |
| consumer_secret: '...', | |
| access_token: '...', | |
| access_token_secret: '...', | |
| timeout_ms: 60*1000, // optional HTTP request timeout to apply to all requests. |
| var T = require("twit"); | |
| var Q = require("q"); | |
| // key and secret for Twitter for iPhone. | |
| // A whitelisted app is needed to access the cards API; you can't just create your own currently. | |
| var TWITTER_CONSUMER_KEY = "IQKbtAYlXLripLGPWd0HUA"; | |
| var TWITTER_CONSUMER_SECRET = "GgDYlkSvaPxGxC4X8liwpUoqKwwr3lCADbz8A7ADU"; | |
| // These you will have to fill in yourself by authorizing Twitter for iPhone for your account. | |
| // How to get the access tokens through OOB authorization is outside the scope of this snippet. | |
| var TWITTER_ACCESS_TOKEN = ""; |
Learn how you can create your own Twitter bot using Node.js and the new Twitter API. The bot will auto retweet in response to tweets with some particular hashtags. (https://goo.gl/4whEIt)
Here are the tools we’ll be using to create the bot —