Skip to content

Instantly share code, notes, and snippets.

View florabtw's full-sized avatar

Flora Moon florabtw

View GitHub Profile
@florabtw
florabtw / fizzbuzz-aaa.js
Last active December 19, 2019 04:23
Web-Scale FizzBuzz
const operations = [
number => number % 3 === 0 && number % 5 === 0 && 'FizzBuzz',
number => number % 3 === 0 && 'Fizz',
number => number % 5 === 0 && 'Buzz',
number => number
];
const toFizzBuzz = number =>
operations.reduce((out, fn) => out || fn(number), false);
@florabtw
florabtw / soundoftext.py
Created September 28, 2019 20:31
Using Sound of Text API in Python 3
import time
import requests
data = { 'engine': 'Google', 'data': { 'voice': 'en-US', 'text': 'Hello, world!' } }
response = requests.post(
'https://api.soundoftext.com/sounds',
headers={'Content-Type':'application/json'},
json=data
)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title></title>
</head>
<body>
<script
src="https://gist.githack.com/ncpierson/4d94970859c679a3884bfe7d00709f52/raw/3452fd99f67414be49d11689ae10055c45afd477/soundoftext.js"
type="text/javascript"
@florabtw
florabtw / soundoftext.js
Created July 4, 2019 04:02
Sound of Text - Browser client
const soundoftext = (() => {
const API_URL = 'https://api.soundoftext.com';
const urls = {
base: 'https://api.soundoftext.com',
request: () => `${urls.base}/sounds`,
status: id => `${urls.base}/sounds/${id}`,
};
const bodies = {
@florabtw
florabtw / counter.rb
Last active December 21, 2018 22:01
Counter Game
module Actions
class Increment
def self.call(state)
{ count: state[:count] + 1 }
end
end
class Decrement
def self.call(state)
{ count: state[:count] - 1 }
@florabtw
florabtw / youdontknowjs.md
Created December 14, 2018 16:14
Notes from You Don't Know Javascript

ALL of the falsy values:

  • ""
  • 0, -0, NaN
  • null, undefined
  • false

The empty array is truthy. However, when loosely compared, it is coerced into an empty string, which is falsy. So,

@florabtw
florabtw / soundoftext.sh
Created August 19, 2018 04:33
POST to Sound Of Text with curl
#! /bin/bash
curl \
-X POST \
-H "Content-Type: application/json" \
-d '{ "data": { "voice": "en-US", "text": "Hello, world!" } }' \
https://api.soundoftext.com/sounds
@florabtw
florabtw / soundoftext.js
Last active February 9, 2021 18:21
Example Usage of Sound of Text API
/* Downloads 'Hello, World', spoken in English, to ./hello.mp3 */
const http = require('https');
const fs = require('fs');
/* Set up handler for response from initial POST request */
function handlePostResponse(data) {
const response = JSON.parse(data); // parse response body from POST
@florabtw
florabtw / Client.scala
Created February 17, 2017 07:51
WebSocket Client and Server
import akka.Done
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.model.ws.TextMessage.Strict
import akka.http.scaladsl.model.ws.{Message, TextMessage, WebSocketRequest}
import akka.stream.scaladsl.{Flow, Keep, Sink, Source, SourceQueue}
import akka.stream.{ActorMaterializer, OverflowStrategy}
import scala.concurrent.ExecutionContext.Implicits.global

Nick's Scala Notes

Basics

This section should be most of the things you need to get going. The goal is that you can read most scala code and write your own simple applications. (Also check out Intermediate and Advanced)

The REPL (Scala playground)