Skip to content

Instantly share code, notes, and snippets.

@sigmaSd
sigmaSd / check.rs
Last active February 2, 2024 23:32
spell check lsp server
// [dependencies]
// serde_json = "1.0.96"
// lsp-types = "=0.94"
// lsp-server = "0.7.1"
use std::error::Error;
use std::io::{Read, Write};
use std::process::Stdio;
use lsp_types::{
@sigmaSd
sigmaSd / nimup.ts
Last active February 27, 2023 14:11
Update nim binaries installed through nimble
import home_dir from "https://deno.land/x/dir@1.5.1/home_dir/mod.ts";
const updateAll = Deno.args.find((a) => a === "--update-all");
const binsPath = home_dir() + "/.nimble/bin";
for (const dirEntry of Deno.readDirSync(binsPath)) {
if (!dirEntry.isSymlink) continue;
const realBinPath = Deno.realPathSync(binsPath + "/" + dirEntry.name);
@sigmaSd
sigmaSd / ronToToml.ts
Last active December 25, 2022 17:13
ron to toml
import {
parse as parseRon,
} from "https://raw.githubusercontent.com/sigmaSd/RonDeno/master/mod.ts";
import { stringify as stringifyToml } from "https://deno.land/std@0.170.0/encoding/toml.ts";
import * as path from "https://deno.land/std@0.170.0/path/mod.ts";
console.log(
stringifyToml(
parseRon(
await fetch(urlFromArg(Deno.args[0])).then((r) => r.text()),
@sigmaSd
sigmaSd / helix.ts
Last active December 19, 2022 17:54
create helix configuration with typescript
import { stringify } from "https://deno.land/std@0.170.0/encoding/toml.ts";
import { ensureDir } from "https://deno.land/std@0.170.0/fs/ensure_dir.ts";
import * as path from "https://deno.land/std@0.170.0/path/mod.ts";
import configDir from "https://deno.land/x/dir@1.5.1/config_dir/mod.ts";
function assert(val: unknown, msg: string): asserts val {
if (val === null || val === undefined) throw new Error(msg);
}
async function main() {
@sigmaSd
sigmaSd / js.nim
Created September 24, 2022 13:32
console.log(js({a:4, b: "hello"}))
import std/genasts
import std/jsconsole
import std/strutils
import std/macros
import std/tables
import std/strformat
import std/sequtils
from std/jsffi import JsObject
macro js*(args: untyped): untyped =
@sigmaSd
sigmaSd / installFn.ts
Last active September 6, 2022 01:25
Install a javascript function as an executable
import cache_dir from "https://deno.land/x/dir@1.5.1/cache_dir/mod.ts";
import { ensureDirSync } from "https://deno.land/std@0.152.0/fs/ensure_dir.ts";
export interface Options {
prelude?: string;
permissions?: string[];
}
// deno-lint-ignore no-explicit-any
export default function installFn(fn: any, options?: Options) {
@sigmaSd
sigmaSd / deno_config.ts
Created August 13, 2022 12:51
Get deno.json that was used in this run by deno
export const getDenoJson = async () => {
const parseMaps = (maps: string) => {
const data = [];
for (const line of maps.split("\n")) {
if (!line) {
continue;
}
const [adddrRange, flags, , , , name] = line.split(/ +/);
data.push({
const maps = () => Deno.readTextFileSync("/proc/self/maps").trim();
const parseMaps = (maps: string) => {
const data = [];
for (const line of maps.split("\n")) {
const [adddrRange, flags, , , , name] = line.split(/ +/);
data.push({
name: name !== "" ? name : undefined,
startAddr: parseInt(adddrRange.split("-")[0], 16),
endAddr: parseInt(adddrRange.split("-")[1], 16),
flags: {
@sigmaSd
sigmaSd / deno-show.ts
Last active March 25, 2022 10:46
Show deno scripts
const homeDir = () => {
switch (Deno.build.os) {
case "linux":
case "darwin":
return Deno.env.get("HOME");
case "windows":
return Deno.env.get("USERPROFILE");
}
};
const binaryPathFromName = (name: string) => `${homeDir()}/.deno/bin/${name}`;
const $ = async (e: string) => {
await Deno.run({
cmd: ["sh", "-c", e],
}).status();
};
const MAKE = "make";
const PUBLIC_DIR = "public";
const OUT_DIR = "build";