Skip to content

Instantly share code, notes, and snippets.

@steveruizok
steveruizok / tldraw-tiptap.ts
Created June 19, 2023 14:26
tldraw x tiptap
import { Node, mergeAttributes } from "@tiptap/core";
import { NodeViewWrapper, ReactNodeViewRenderer } from "@tiptap/react";
import { Tldraw } from "@tldraw/tldraw"; // use @tldraw/tldraw@canary
import "@tldraw/tldraw/tldraw.css";
function Component() {
return (
<NodeViewWrapper className="react-component">
<div style={{ width: "100%", height: 500 }}>
<Tldraw />
@Ruminat
Ruminat / groovy-language-definition-for-monaco.ts
Created February 5, 2022 12:32
A Groovy language for monaco editor
import { languages } from "monaco-editor";
function getTokens(tokens: string, divider = "|"): string[] {
return tokens.split(divider);
}
const wordPattern = /(-?\d*\.\d\w*)|([^`~!@#%^&*()\-=+[{\]}\\|;:'",./?\s]+)/g;
const brackets: languages.CharacterPair[] = [
["{", "}"],
@dz4k
dz4k / Draggable._hs
Last active December 25, 2023 10:47
Draggable window in _hyperscript
-- Usage: _="install Draggable(dragHandle: .titlebar in me)"
behavior Draggable(dragHandle)
init
if no dragHandle set the dragHandle to me
end
on pointerdown(clientX, clientY) from dragHandle
halt the event
trigger draggable:start -- hooks, e.g. for adding a drop shadow while dragging
measure my x, y
@jfuellert
jfuellert / ScrollableView.swift
Last active June 7, 2024 02:55
A scrollable SwiftUI view, UIScrollView wrapper. ScrollableView lets you read and write content offsets for scrollview in SwiftUI, with and without animations.
import SwiftUI
struct ScrollableView<Content: View>: UIViewControllerRepresentable, Equatable {
// MARK: - Coordinator
final class Coordinator: NSObject, UIScrollViewDelegate {
// MARK: - Properties
private let scrollView: UIScrollView
var offset: Binding<CGPoint>
const fs = require("fs");
const bundle = fs.readFileSync("path-to-webpack-bundle.html", "utf8");
const escaped = JSON.stringify(bundle);
const js = `export default ${escaped}`;
fs.writeFileSync("javascript-output-file.ts", js);
@timothycosta
timothycosta / UIScrollViewWrapper.swift
Created July 5, 2019 03:25
UIScrollView wrapped for SwiftUI
//
// UIScrollViewWrapper.swift
// lingq-5
//
// Created by Timothy Costa on 2019/07/05.
// Copyright © 2019 timothycosta.com. All rights reserved.
//
import SwiftUI
@miguelmota
miguelmota / monitor_script.sh
Created March 14, 2018 21:32
AWS bastion host monitor script
# https://aws.amazon.com/blogs/security/how-to-record-ssh-sessions-established-through-a-bastion-host/
######################################################
# Config variables
######################################################
BUCKET_NAME="my-bastion-host"
######################################################
# Log commands to log file
@izabera
izabera / asciinema-to-scriptreplay
Last active March 23, 2023 12:32
convert between asciinema and scriptreplay
#!/bin/bash
exec {times}> times {typescript}> typescript < "${1-/dev/stdin}"
while read -r; do [[ $REPLY = ' "stdout": [' ]] && break; done # skip to this line
LANG=C
printf "Script started on %(%c)T\n" -1 >&"$typescript" # dummy
while read -r open; [[ $open = '[' ]]; do
read -r elapsed; read -r string; read -r close
eval printf %b%n "$string" characters >&"$typescript" # put count in $characters
printf "%s %s\n" "${elapsed%,}" "$characters" >&"$times"
done
@sskrla
sskrla / SecureExpressionASTTransformation.groovy
Last active August 14, 2023 13:42
Secure Groovy Expression / Method Invocations
import org.codehaus.groovy.ast.ASTNode
import org.codehaus.groovy.ast.ClassCodeVisitorSupport
import org.codehaus.groovy.ast.ClassHelper
import org.codehaus.groovy.ast.expr.ArgumentListExpression
import org.codehaus.groovy.ast.expr.BinaryExpression;
import org.codehaus.groovy.ast.expr.ConstantExpression
import org.codehaus.groovy.ast.expr.Expression
import org.codehaus.groovy.ast.expr.MethodCallExpression
import org.codehaus.groovy.ast.expr.MethodPointerExpression
import org.codehaus.groovy.ast.expr.PropertyExpression
@rustle
rustle / gist:4342284
Created December 20, 2012 01:30
Cornerstone with Kaleidoscope 2 beta

Cornerstone does not yet officially support Kaleidoscope 2, so to work with the latest beta of Kaleidoscope 2 (Build 99 and up) here is how to get set up:

Follow the instructions here Cornerstone External Compare Tools under the heading Custom Compare Scripts

The custom scripts contents should be

#!/usr/bin/env bash

/usr/local/bin/ksdiff --partial-changeset -- "$1" "$2"