Level up your Twilio API skills in TwilioQuest, an educational game for Mac, Windows, and Linux. Download Now
Build the future of communications.
Start building for free
  • By Sam Agnew
    Using Python and Twilio Messaging to find out if the Suez Canal is still blocked Copy of Generic Blog Header 1(4).png

    Recently a 200,000 ton container ship named the Ever Given has become stuck in the Suez Canal, halting one of the world's busiest waterways and disrupting global supply chains. And it looks like it might take weeks to move it. Luckily for those on the edge of their seats, with the Marine Traffic API we can access the location of marine vessels programmatically.

    My coworker Kelley Robinson used this to create a Twilio phone number that you can text to see if the Ever Given is still stuck. Try it out by texting +1 (586) 800-BOAT, which is +1 (586) 800-2628, to get the status of the situation.

    Boat still stuck? Text message

    Let's walk through how you could build your own version of this, using Twilio Programmable Messaging, Flask, and the Marine Traffic API.

    Setting up your environment

    Make sure to have your Python environment set up before we get started. …

    Read More
  • By Sam Agnew
    Asynchronous HTTP Requests in Python with aiohttp and asyncio Copy of Generic Blog Header 3(4).png

    Asynchronous code has increasingly become a mainstay of Python development. With asyncio becoming part of the standard library and many third party packages providing features compatible with it, this paradigm is not going away anytime soon.

    Let's walk through how to use the aiohttp library to take advantage of this for making asynchronous HTTP requests, which is one of the most common use cases for non-blocking code.

    What is non-blocking code?

    You may hear terms like "asynchronous", "non-blocking" or "concurrent" and be a little confused as to what they all mean. According to this much more detailed tutorial, two of the primary properties are:

    • Asynchronous routines are able to “pause” while waiting on their ultimate result to let other routines run in the meantime.
    • Asynchronous code, through the mechanism above, facilitates concurrent execution. To put it differently, asynchronous code gives the look and feel of concurrency.

    So asynchronous …

    Read More
  • By Sam Agnew
    4 outils pour faire du Web Scraping en Node.js 4-outils-web-scraping-node-js

    Les données dont vous avez besoin sont parfois disponibles en ligne, mais ne sont pas disponibles via une API REST dédiée.

    Heureusement pour les développeurs JavaScript, il existe une variété d'outils disponibles dans Node.js pour le scraping et l'analyse des données directement à partir de sites web à exploiter dans vos projets et applications.

    Parcourons quatre de ces bibliothèques pour voir comment elles fonctionnent et comment elles se comparent les unes aux autres !

    Mais d’abord, assurez-vous que vous avez des versions à jour de Node.js (au moins 12.0.0) et de npm installées sur votre machine. Exécutez la commande suivante dans le répertoire où vous souhaitez placer votre code:

    npm init --yes
    

    Pour certaines de ces applications, nous utiliserons la bibliothèque Got pour faire des requêtes HTTP. Installez-la dans le même répertoire, avec cette commande:

    npm install got@11.0.2
    

    Essayons maintenant de trouver tous les liens vers des fichiers MIDI …

    Read More
  • By Sam Agnew
    Web Scraping et Analyse du HTML en Python avec Beautiful Soup web-scraping-analyse-html-python-beautiful-soup

    Internet offre une incroyable diversité d’informations destinées à la consommation humaine. Mais il est souvent difficile d'accéder à ces données par voie programmatique, si elles ne se présentent pas sous la forme d'une API REST dédiée. Grâce à des outils Python comme Beautiful Soup, vous pouvez récupérer, analyser des pages Web puis utiliser ces données dans vos projets.

    Par exemple : Comment récupérer des données MIDI sur Internet pour entraîner un réseau neuronal avec Magenta qui sera capable de générer de la musique rétro Nintendo ?

    Nous avons besoin pour cela d'un ensemble de musiques MIDI provenant d'anciens jeux Nintendo. Beautiful Soup nous permet d’obtenir ces données à partir des Video Game Music Archive.

    Démarrage et installation des dépendances

    Avant de continuer, assurez-vous d’avoir bien installé la mise à jour de Python 3 et de pip. Créez et activez un environnement virtuel avant d'installer toutes les dépendances. …

    Read More
  • By Sam Agnew
    5 Must-Have Vim Plugins That Will Change Your Workflow Copy of Generic Blog Header 2(1).png

    One thing Vim users love about their favorite text editor is it's seemingly endless extensibility. On top of configuring basic mappings, settings, and behaviors in your .vimrc, there are a ton of awesome plugins that extend Vim's functionality. As someone who has been using Vim as his primary editor for about 7 years now, I'm going to share some of the ones that I think are important for any Vim user.

    Installing and Managing Plugins

    Before moving onto the plugins I want to cover, let's talk about how to actually install and manage plugins in Vim. There are multiple ways to do this.

    Native Package Support in Vim 8

    As of the release of Vim 8, Vim now has built in support for packages, which you can use to install these plugins. In this post, I will be linking a GitHub repository for each plugin I talk about. …

    Read More
  • By Sam Agnew
    5 Awesome Vim Tricks to Spice up your .vimrc Copy of Generic Blog Header 4(5).png

    If there's one thing Vim users love more than saving a few seconds per day on keystrokes, it's trading tips and tricks with others about their own setup. As someone who's been using Vim for 7 years now as his primary text editor, I'm going to do my part by sharing some neat things from my .vimrc that people have asked me about at conferences and hackathons in the past.

    For each of these examples, I'll provide the code for you to copy/paste into your own .vimrc and try to explain what's going on. Take what you think works for you and leave the rest!

    Crosshair style cursor highlighting

    One thing that people ask me about often is the crosshair style cursor that I use in my configuration. All you need to do to make your cursor look like this:

    Cursor Crosshair

    ...is add these lines to your .vimrc file (typically located …

    Read More
  • By Sam Agnew
    Node.jsでAysnc/Awaitを使ってHTTPリクエストを行う5つの方法 5 ways to make http request in node,js JP

    この記事はデベロッパーエバンジェリストのSam Agnewがこちらで執筆した記事を日本語化したものになります。

    HTTPリクエストはモダンなプログラミング言語におけるコアとなる機能であり、多くの開発者が新しい環境に慣れる際に学習する項目の1つです。Node.jsではもともとの言語にこの機能が備わっており、また開発者コミュニティでも多くのソリューションが開発されています。最も人気のあるものをいくつか見ていきましょう。

    数年前、同じような記事をこちらで執筆しています。しかし、その後JavaScriptではaync/awaitを用いた非同期プログラミング手法が普及し主流となったため、ネットワークリクエストがこれまで以上に簡単になりました。このことに加え、HTTPライブラリとしてこれまで多くのNodeプロジェクトで利用されてきたRequestが非推奨となりました。まさにこのガイドを更新する良いタイミングです。

    他の投稿と同様に、コード例ではNASAのAstronomy Picture of the Day API をJSON APIとして使用しています。

    Pizza GIF

    実際に試される場合は次に進む前に最新バージョンのNode.jsおよびnpmがインストールされていることをご確認ください。

    HTTP - 標準ライブラリ

    比較のためにPromiseとasync/awaitを使わない標準のHTTPモジュールを見てみましょう。このモジュールは、依存するパッケージやライブラリがないという利点がありますが、ほかのソリューションに比べて開発者フレンドリーとは言えません。

    以下のコードは、NA …

    Read More
  • By Sam Agnew
    Send an SMS from Twitch Chat with Node.js and Twilio Programmable Messaging Copy of Generic Blog Header 1(3).png

    From watching people play your favorite games, to seeing awesome things built with code, to cooking up a storm in the kitchen, you can find a huge variety of content being streamed live on Twitch.tv. A mainstay of many Twitch channels is having a bot to engage with viewers in chat to automate things such as tasks for moderators or sharing contextual information with newcomers. Chatbots can even control Pokemon games!

    With Twilio Programmable Messaging, you can write code to send and receive text messages. This could be useful for streamers for something like notifying subscribed users of when they're doing something particularly cool on stream.

    Let's walk through how to create a chatbot to send SMS notifications to users on your own channel with JavaScript using Node.js.

    Twitch Plays Pokemon

    Taking care of dependencies

    Before writing any code, you will need an up to date version of Node.js and …

    Read More
  • By Sam Agnew
    Creating a GPT-3 Twitch Chatbot with Node.js Copy of Generic Blog Header 4(4).png

    A mainstay of many popular channels that stream on Twitch.tv is having a bot to engage with viewers in chat to automate things such as tasks for moderators or sharing contextual information with newcomers. OpenAI's API for their new GPT-3 model provides a very versatile, general-purpose “text in, text out” interface, making it applicable to virtually any language task.

    Naturally, this seems like a match made in heaven. So let's walk through how to unleash the powers of GPT-3 with Twitch chat bots on your own channel using Node.js.

    Taking care of dependencies

    Before writing any code, you will need an up to date version of Node.js and npm installed.

    Navigate to the directory where you want this code to live and run the following command in your terminal to create a package for this project:

    npm init --yes
    

    The --yes argument runs through all of the prompts that you …

    Read More
  • By Sam Agnew
    Creating Twitch Chat Bots with Node.js Copy of Generic Blog Header 2.png

     

    From watching people play your favorite games, to seeing awesome things built with code, to cooking up a storm in the kitchen, you can find a huge variety of content being streamed live on Twitch.tv. A mainstay of many Twitch channels is having a bot to engage with viewers in chat to automate things such as tasks for moderators or sharing contextual information with newcomers. Chat bots can even control Pokemon games!

    Let's walk through how to unleash the powers of Twitch chat bots on your own channel with JavaScript using Node.js.

    Twitch Plays Pokemon

    Taking care of dependencies

    Before writing any code, you will need an up to date version of Node.js and npm installed.

    Navigate to the directory where you want this code to live and run the following command in your terminal to create a package for this project:

    npm init --yes
    

    The --yes argument runs through …

    Read More
  • Newer
    Older
    Sign up and start building
    Not ready yet? Talk to an expert.