Skip to content

Instantly share code, notes, and snippets.

View 13point5's full-sized avatar

Sriraam Raja 13point5

View GitHub Profile
@13point5
13point5 / App.tsx
Created July 14, 2023 17:05
Customising the mention list using custom functions in `tiptap`
import { useEditor, EditorContent } from "@tiptap/react";
import StarterKit from "@tiptap/starter-kit";
import Mention from "@tiptap/extension-mention";
import "./mention/styles.css";
import suggestion from "./mention/suggestion";
const getSuggestions = ({ id, query }: { id: string; query: string }) => {
// do something with id and query
@13point5
13point5 / .zshrc
Last active August 9, 2020 18:09
Starter settings for Windows Terminal when using WSL2
# wt and wsl
export win10="/mnt/c/Users/Bharath"
function coolpanes() {
cmd.exe /c "wt.exe" -p $1 -d $2 \; split-pane -p $1 -d $2 \; split-pane -H -p $1 -d $2 &
}
alias lbla="coolpanes \"Ubuntu - Projects\" //wsl$/Ubuntu/home/bharath/projects/bla"
function cwdpanes() {
# Inefficient
[func(item) for item in values if func(item) < 13.5]
# Efficient
[result for item in values if (result := func(item)) < 13.5]
# Conditional statements
# Normal
var = some_function()
if var:
do_something()
# Using :=
if var := some_function():
do_something()
# Current code
while True:
line = fp.readline()
if not line:
break
m = define_rx.match(line)
if m:
n, v = m.group(1, 2)
try:
v = int(v)
# Before the walrus operator
line = f.readline()
while line:
process(line)
line = f.readline()
# After
while line := f.readline():
process(line)
@13point5
13point5 / coolformula.py
Last active December 29, 2019 14:54
The only mathematical formula to find the smallest number whose digits sum up to s and has m digits.
# Author: Bharath Sriraam R R
def bla(m,s):
n=(s+7)//9
sl=9*n -7
c=10**(n-1)
b=10**(m-1)
p=int((2+s-sl)*c -1)
return p+b