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
# This demonstrates that, when using async/await, a crash in the task will crash the caller | |
defmodule Tasker do | |
def good(message) do | |
IO.puts message | |
end | |
def bad(message) do | |
IO.puts message | |
raise "I'm BAD!" | |
end |
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
""" | |
Simple Linear Probabilistic Counters | |
Credit for idea goes to: | |
http://highscalability.com/blog/2012/4/5/big-data-counting-how-to-count-a-billion-distinct-objects-us.html | |
http://highlyscalable.wordpress.com/2012/05/01/probabilistic-structures-web-analytics-data-mining/ | |
Installation: | |
pip install smhasher | |
pip install bitarray |
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
<script> | |
import { onMount } from 'svelte'; | |
import { StreamChat } from 'stream-chat/dist/index.js'; | |
export let appName; | |
let loggedIn = false; | |
let online = false; | |
let token = ''; | |
let username = ''; | |
let message = ''; |
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
<style global> | |
@tailwind base; | |
@tailwind components; | |
@tailwind utilities; | |
</style> |
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 svelte from 'rollup-plugin-svelte'; | |
import resolve from '@rollup/plugin-node-resolve'; | |
import commonjs from '@rollup/plugin-commonjs'; | |
import livereload from 'rollup-plugin-livereload'; | |
import { terser } from 'rollup-plugin-terser'; | |
import sveltePreprocess from 'svelte-preprocess'; | |
import replace from '@rollup/plugin-replace'; | |
import { config } from 'dotenv'; | |
config(); |
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 purgecss = require('@fullhuman/postcss-purgecss')({ | |
content: ['./src/**/*.svelte', './src/**/*.html'], | |
whitelistPatterns: [/svelte-/], | |
defaultExtractor: content => content.match(/[A-Za-z0-9-_:/]+/g) || [] | |
}) | |
module.exports = { | |
plugins: [ | |
require('tailwindcss'), | |
...(!process.env.ROLLUP_WATCH ? [purgecss] : []) |
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
npx degit sveltejs/template . | |
npm i # install | |
npm i stream-chat dotenv | |
npm i -D postcss postcss-load-config svelte-preprocess tailwindcss @fullhuman/postcss-purgecss @rollup/plugin-replace # development dependencies | |
npx tailwind init | |
touch postcss.config.js | |
cp ../backend/.env . # Make a copy of backend's .env in frontend | |
npm run dev # and visit http://localhost:5000 in the browser |
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
$ curl -X POST http://kong:8001/services/kc-chat-backend/plugins \ | |
--data "name=cors" \ | |
--data "config.origins=*" \ | |
--data "config.methods=GET" \ | |
--data "config.methods=POST" \ | |
--data "config.methods=OPTIONS" \ | |
--data "config.headers=Accept" \ | |
--data "config.headers=Accept-Version" \ | |
--data "config.headers=Content-Length" \ | |
--data "config.headers=Content-MD5" \ |
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
$ curl -i -X GET --url http://localhost:8000/api/kongchat/ping | |
# Sample output | |
HTTP/1.1 200 OK | |
Content-Type: application/json; charset=utf-8 | |
Content-Length: 18 | |
Connection: keep-alive | |
X-Powered-By: Express | |
ETag: W/"12-6FyCUNJCdUkgXM8yXmM99u6fQw0" |
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
$ curl -i -X POST --url http://localhost:8001/services/kc-chat-backend/routes \ | |
--data 'paths[]=/api/kongchat' --data 'strip_path=false' --data 'methods[]=GET' \ | |
--data 'methods[]=POST' | |
# Sample output | |
HTTP/1.1 201 Created | |
Content-Type: application/json; charset=utf-8 | |
Connection: keep-alive | |
Access-Control-Allow-Origin: * |
NewerOlder