Skip to content

Instantly share code, notes, and snippets.

Avatar

Velotio Technologies velotiotech

View GitHub Profile
View quiz.go
package main
import (
"fmt"
"sync"
)
var wg sync.WaitGroup
func myFunc(msg string) {
fmt.Println(msg)
}
func main() {
View Quiz.js
var rpm = "500";
let speed = "170";
{
var rpm = Number(rpm);
speed = speed/0;
let tourque = "50";
console.log(speed)
}
View quiz.py
def g1(s={}):
f1 = lambda a: a.strip().split()
f2 = lambda a: map(lambda x: s[x] if x in s else s.setdefault(x, len(s) + 1), a)
f3 = lambda a: "->".join(map(lambda b: str(b), a))
return f1, f2, f3
def g2(x, fs):
for f in fs:
x = f(x)
return x
View install_dependencies.sh
npm i quill quill-cursors webpack webpack-cli webpack-dev-server y-quill y-websocket yjs
View index.js
import Quill from "quill";
import * as Y from 'yjs';
import { QuillBinding } from 'y-quill';
import { WebsocketProvider } from 'y-websocket';
import QuillCursors from "quill-cursors";
// Register QuillCursors module to add the ability to show multiple cursors on the editor.
Quill.register('modules/cursors', QuillCursors);
window.addEventListener('load', () => {
View create_ydoc.js
window.addEventListener('load', () => {
const ydoc = new Y.Doc();
const provider = new WebsocketProvider('ws://localhost:3312', 'velotio-demo', ydoc);
const type = ydoc.getText('Velotio-Blog');
});
View binding.js
window.addEventListener('load', () => {
// ### ABOVE CODE HERE ###
const editorContainer = document.getElementById('editor');
const toolbarOptions = [
['bold', 'italic', 'underline', 'strike'], // toggled buttons
['blockquote', 'code-block'],
[{ 'header': 1 }, { 'header': 2 }], // custom button values
[{ 'list': 'ordered' }, { 'list': 'bullet' }],
[{ 'script': 'sub' }, { 'script': 'super' }], // superscript/subscript
View connect_button.js
window.addEventListener('load', () => {
// ### ABOVE CODE HERE ###
const connectBtn = document.getElementById('connect-btn');
connectBtn.addEventListener('click', () => {
if (provider.shouldConnect) {
provider.disconnect();
connectBtn.textContent = 'Connect'
} else {
provider.connect();
View index.html
<!DOCTYPE html>
<html>
<head>
<title>Yjs Quill Example</title>
<script src="./dist/index.bundle.js" async defer></script>
<link rel=stylesheet href="//cdn.quilljs.com/1.3.6/quill.snow.css" async defer>
</head>
<body>
<button type="button" id="connect-btn">Disconnect</button>
<div id="editor" style="height: 500px;"></div>
View webpack.config.ts
const path = require('path');
module.exports = {
mode: 'development',
devtool: 'source-map',
entry: {
index: './index.js'
},
output: {
globalObject: 'self',