In PHP, Exception
s can be caught:
try {
throw new \DomainException('input out of bounds');
} catch (\Exception $e) {
echo "got exception\n";
} finally {
Usage example:
import { titleCase } from "https://gist.githubusercontent.com/crabmusket/cd10f732e847afd023a00f6a45bd0d72/raw/558463e1c2a5aa910915a21396b105cefd1254d9/title_case.ts";
console.log(titleCase("deno is AWESOME"));
console.log(titleCase("words-can contain_punctuation"));
console.log(titleCase(" spacing is preserved"));
FROM ubuntu:16.04 | |
RUN apt-get update && apt-get install \ | |
build-essential \ | |
clang-3.8 \ | |
curl \ | |
git \ | |
libxml2 \ | |
python-dev \ | |
-y |
Each of these modules is a single file consisting of no more than a page or two of code, which provide some useful 'generic' feature. These modules could be copied as-is into any TypeScript project, but they're designed to work with Deno. Deno's URL loading makes it very easy to import them.
An asynchronous semaphore utility class meant to work with Deno. You can use it to implement rate-limiting and other concurrency patterns.
Usage example:
import { Semaphore } from "https://gist.githubusercontent.com/crabmusket/681b4f81ed05716f8dd10ac88d1d960b/raw/5e7c18013e896425d1048324f8668932f23437df/semaphore.ts";
/** For the spec of the JSON type, see http://json.org */ | |
export type JsonValue = JsonObject | JsonArray | number | string | boolean | null; | |
/** JSON objects can have any string key. */ | |
export interface JsonObject {[key: string]: JsonValue}; | |
/** For the explanation of this type, see https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540 */ | |
export interface JsonArray extends Array<JsonValue> {}; | |
/** Narrow the type of a JsonValue to check if it's an object. */ |
module Alphabet ( | |
Alphabet, | |
encodeWithAlphabet, | |
decodeFromAlphabet | |
) where | |
import Prelude | |
import Data.List(elemIndex, mapAccumR) | |
import Data.Maybe(fromMaybe) |
# https://blog.notryan.com/server.py | |
# https://www.reddit.com/r/programming/comments/gdxh3w/http_blog_server_100_lines_of_c_in_a_closet/fpkqvqw/ | |
import socket | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
sock.bind(("0.0.0.0", 8080)) | |
sock.listen(1) | |
while True: |