We'll use NixOps to deploy, so we need to install it
nix-env -i nixopsAnd to deploy on DigitalOcean we need to have an account and create an API access token for it.
| <!-- $Header: /cvsroot/autodoc/autodoc/html.tmpl,v 1.4 2006/05/16 19:01:27 rbt Exp $ --> | |
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" | |
| "http://www.w3.org/TR/html4/strict.dtd"> | |
| <html> | |
| <head> | |
| <title>Index for synapse</title> | |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
| <style type="text/css"> | |
| BODY { |
| import timeit | |
| # Starting from a particular crouton in the salad, traverse down to all other croutons | |
| def myDFS(salad,crouton,length,paths,path=[]): | |
| if crouton in path: | |
| return | |
| path=path+[crouton] | |
| if len(path)==length: | |
| paths.append(path) | |
| else: |
| # To use this, you need Python 3.5+ and pip. | |
| # | |
| # 1. Make a new Discord app with a bot. https://discordapp.com/developers/applications/ | |
| # | |
| # 2. Set environment variable SIMPLEWORDS_TOKEN on your computer to the bot's Token. | |
| # Unix/Mac: export SIMPLEWORDS_TOKEN=MzABCDefghIJKLmnopQRSTuv.EnZ3kg.b5bdD74CKCr3du679hkemGJ7R7N | |
| # PowerShell: $env:SIMPLEWORDS_TOKEN='MzABCDefghIJKLmnopQRSTuv.EnZ3kg.b5bdD74CKCr3du679hkemGJ7R7N' | |
| # | |
| # 3. Invite the bot to your server: https://stackoverflow.com/a/37743722/257418 | |
| # |
| // Given previous tokens, predict the next token (and runners up) | |
| let predictNextToken (previousKinds : SyntaxKind[]) : Prediction[] = | |
| if ios11 then | |
| let model : MLModel = model.Value // Load the cached model | |
| let mutable predictions : Prediction[] = [| |] | |
| // RNNs require external memory | |
| let mutable lstm_1_h : MLMultiArray = null | |
| let mutable lstm_1_c : MLMultiArray = null |
| <div class="canvas"> | |
| <div id="totalCounter" class="total-counter"></div> | |
| <div id="clap" class="clap-container"> | |
| <i class="clap-icon fa fa-hand-paper-o"></i> | |
| </div> | |
| <div id="clicker" class="click-counter"> | |
| <span class="counter"></span> | |
| </div> |
| #! /bin/sh | |
| set -e | |
| set -u | |
| set -x | |
| # configure this! | |
| hostname="nixos" | |
| password="abc123" | |
| diskdev=/dev/sda |
We'll use NixOps to deploy, so we need to install it
nix-env -i nixopsAnd to deploy on DigitalOcean we need to have an account and create an API access token for it.
Making a bot? Making a bot in Python? Making a bot in Python that uses the Mastodon API? If so, chances are you need to get some credentials. Here's how I did it!
(The following tutorial uses Python 2.7, but if you're using Python 3+ everything should work substantially the same.)
I just started using it, but it looks like Mastodon.py is a pretty great library for working with the Mastodon API! However, all of the authentication examples use static files to store credentials, which I don't like—I'm afraid I'll accidentally push them to Github. I like to keep my authentication as close to the actual command that runs the program as possible, so usually I pass them on the command line to the script running my bot. To do this, I need to get the appropriate credentials on their own, as separate strings that I can cut and paste.
| // This library is free software; you can redistribute it and/or | |
| // modify it under the terms of the GNU Lesser General Public | |
| // License as published by the Free Software Foundation; either | |
| // version 3.0 of the License, or (at your option) any later version. | |
| // | |
| // This library is distributed in the hope that it will be useful, | |
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| // Lesser General Public License for more details. | |
| // |