Skip to content

Instantly share code, notes, and snippets.

View ukchukx's full-sized avatar
💭
Unus sed leo

Uk ukchukx

💭
Unus sed leo
View GitHub Profile
@ukchukx
ukchukx / task1.exs
Created June 24, 2020 15:39 — forked from moklett/task1.exs
Elixir Task - Crash Handling
# 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
@ukchukx
ukchukx / lp_counters.py
Created March 20, 2020 10:03 — forked from devdazed/lp_counters.py
Simple Linear Probabilistic Counters
"""
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
<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 = '';
<style global>
@tailwind base;
@tailwind components;
@tailwind utilities;
</style>
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();
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] : [])
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
$ 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" \
$ 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"
$ 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: *