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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public BigInteger derangement(int num) { | |
if (num == 0) { | |
return BigInteger.ONE; | |
} | |
BigDecimal sum = BigDecimal.ZERO; | |
for (int i = 0; i <= num; i++) { | |
BigDecimal fact = new BigDecimal(factorial(i)); | |
BigDecimal toAdd = BigDecimal.valueOf(Math.pow(-1, i)).divide(fact, MathContext.DECIMAL128); | |
sum = sum.add(toAdd); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TKK = hours since epoch | |
var window = { | |
TKK: parseInt(new Date().getTime() / 1000 / 60 / 60) | |
}; | |
var t = "a"; | |
var cb = "&"; | |
var mf = "="; | |
var k = ""; | |
var dd = "."; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TKK = hours since epoch | |
var window = { | |
TKK: parseInt(new Date().getTime() / 1000 / 60 / 60) | |
}; | |
var t = "a"; | |
var dd = "."; | |
var Vb = "+-a^+6"; | |
var Tb = "+"; | |
var Ub = "+-3^+b+-f"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
curl \ | |
-X POST \ | |
-H "Content-Type: application/json" \ | |
-d '{ "data": { "voice": "en-US", "text": "Hello, world!" } }' \ | |
https://api.soundoftext.com/sounds |
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,
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Actions | |
class Increment | |
def self.call(state) | |
{ count: state[:count] + 1 } | |
end | |
end | |
class Decrement | |
def self.call(state) | |
{ count: state[:count] - 1 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = { |
OlderNewer