Skip to content

Instantly share code, notes, and snippets.

View alejandrogarciasalas's full-sized avatar

Alejandro García Salas alejandrogarciasalas

View GitHub Profile
@waptik
waptik / index.ts
Created July 12, 2021 16:48
A custom extension for tiptap v2 to for image upload
import { Node, nodeInputRule } from "@tiptap/core";
import { mergeAttributes } from "@tiptap/react";
import { uploadImagePlugin, UploadFn } from "./upload_image";
/**
* Tiptap Extension to upload images
* @see https://gist.github.com/slava-vishnyakov/16076dff1a77ddaca93c4bccd4ec4521#gistcomment-3744392
* @since 7th July 2021
*
/* sidenotes.js: standalone JS library for parsing HTML documents with Pandoc-style footnotes and dynamically repositioning them into the left/right margins, when browser windows are wide enough.
Sidenotes are superior to footnotes where possible because they enable the reader to immediately look at them without requiring user action to 'go to' or 'pop up' the footnotes; even floating footnotes require effort by the reader.
sidenotes.js is inspired by the Tufte-CSS sidenotes (https://edwardtufte.github.io/tufte-css/#sidenotes), but where Tufte-CSS uses static footnotes inlined into the body of the page (requiring modifications to Pandoc's compilation), which doesn't always work well for particularly long or frequent sidenotes, sidenotes.js will rearrange sidenotes to fit as best as possible, and will respond to window changes.
Particularly long sidenotes are also partially 'collapsed'.
Author: Said Achmiz
2019-03-11
license: MIT (derivative of footnotes.js, which is PD)
*/
@slava-vishnyakov
slava-vishnyakov / readme.md
Last active May 7, 2024 04:49
How to upload images with TipTap editor
  1. Create a file Image.js from the source below (it is almost a copy of Image.js from tiptap-extensions except that it has a constructor that accepts uploadFunc (function to be called with image being uploaded) and additional logic if(upload) { ... } else { ... previous base64 logic .. } in the new Plugin section.
import {Node, Plugin} from 'tiptap'
import {nodeInputRule} from 'tiptap-commands'

/**
 * Matches following attributes in Markdown-typed image: [, alt, src, title]
 *
@swyxio
swyxio / Write My Code For Me: Cheating at Developer Experience.md
Last active October 16, 2021 22:01
some thoughts on adding templating/scaffolding to CLIs and how it can be done well

Write My Code For Me: Cheating at Developer Experience

this is a draft of a blogpost that i'll be posting somewhere. Feedback welcome! also feel free to ping me on twitter

I've recently been working on some CLI that involves printing out a bunch of boilerplate template code for developer convenience. I found that there were a few interesting DX angles to this and figured I should write down the rough problem areas and the stances I chose. Most of us are familiar with CLIs like https://yeoman.io/, this task is variously called "scaffolding" or "templating" or some such similar term, with varying degrees of intelligence in the task. I'll refer to it as "templating" in this essay.

Part 1: Should You?

Caramel, not just Sugar

@asela38
asela38 / java8-one-liners-for-statistical-properties.md
Last active May 11, 2023 23:54
Java 8 One liners for statistical properties : Mean, Mode, Median(Q2), Q1, Q2, Variance, Standard Deviation

While working on a Hacker Rank Problem I wrote few one lines using java stream to find mean, median, mode, Q1, Q3, variance and standard deviation. Thought to share since it's quite interesting.

        // mean
        double mean = list.stream().mapToInt(Integer::intValue).average().getAsDouble();
        System.out.println(mean);
        
        // mode - create count map using group by and sorted with custom comparator to give minimum from competing probable mode values
        Integer mode = list.stream()
                .collect(Collectors.groupingBy(i -> i, () -> new TreeMap<Integer, Long>(), Collectors.counting()))
@ldez
ldez / gmail-github-filters.md
Last active May 16, 2024 11:07
Gmail and GitHub - Filters

Gmail and GitHub

How to filter emails from GitHub in Gmail and flag them with labels.

The labels in this document are just examples.

Pull Request

Filter Label
# GIT heart FZF
# -------------
is_in_git_repo() {
git rev-parse HEAD > /dev/null 2>&1
}
fzf-down() {
fzf --height 50% --min-height 20 --border --bind ctrl-/:toggle-preview "$@"
}
@tjbenton
tjbenton / virtualbox-vagrant-nuclear-option.sh
Created April 6, 2016 17:28
Completely uninstall VirtualBox and Vagrant and reinstall through brew
# update brew because `brew update` is broken after updating to El Capitan
cd `brew --prefix`
git fetch origin
git reset --hard origin/master
sudo shutdown -r now # restart the computer
# open terminal and run the following
brew update
brew cleanup
@paulirish
paulirish / what-forces-layout.md
Last active May 20, 2024 06:33
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@tsiege
tsiege / The Technical Interview Cheat Sheet.md
Last active May 19, 2024 17:40
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

ANNOUNCEMENT

I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!






\