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,
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); |
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" |
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 = { |
module Actions | |
class Increment | |
def self.call(state) | |
{ count: state[:count] + 1 } | |
end | |
end | |
class Decrement | |
def self.call(state) | |
{ count: state[:count] - 1 } |
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,
#! /bin/bash | |
curl \ | |
-X POST \ | |
-H "Content-Type: application/json" \ | |
-d '{ "data": { "voice": "en-US", "text": "Hello, world!" } }' \ | |
https://api.soundoftext.com/sounds |
/* 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 |
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 |
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)