Skip to content

Instantly share code, notes, and snippets.

@silicakes
silicakes / zellij_sessionizer
Last active June 15, 2023 16:25
zellij_sessionizer
#!/usr/bin/env bash
# Inspired by https://github.com/ThePrimeagen/.dotfiles/blob/602019e902634188ab06ea31251c01c1a43d1621/bin/.local/scripts/tmux-sessionizer
# Just for zellij
# alows you to use `fzf` to navigate into a desire folder and either start or attach into a zellij session
# If you run it from inside zellij, it will open the newly selected folder in a new pane
# Demo of the original: https://youtu.be/bdumjiHabhQ?t=269
# 1. Place the script in your path
@silicakes
silicakes / index.ts
Created September 19, 2022 12:20
Use a generic as a restrictive typed for mapped properties, avoiding conditional types
/*
* Conditional types can become tedious to maintian as nested ternary syntax is hard to understand
* The following suggests a different approach, using a mapped key: value pair where adding additional rules and -
* restrictions becomes much easier to read and maintain.
* [TSPlayground](https://www.typescriptlang.org/play?ssl=38&ssc=20&pln=38&pc=24#code/KYOwrgtgBAgiCWECGAbKBvAsAKCnqAIgPIDiUAvFAEQAmA9gOZUA0O+UAwjACoXUDGSAC4s2+AGIBJAMoAJPlQBm8AM4ALKjgC+OXdngghwAE6Kk-YIUYAFY3QAOKjGLwAjJMYDWALiiu6dCjASCAA3Np6Bkam5pbiqmq2Dk5YuPgqAO6IvkLGYMAR2DhRJmYWsAjIKACySPbOaXgA2nCIqAB0xCQAur4ENnaOrI1QLZUdUnK9UPHqSY6FekIAnvZxAXwAPLzAAB5GIDROnsDLdIoVbTV1AHwAFCFXvtzMUDTCSL6tVbX2TdzdACUFBuUAAbnR4DRwkVsCs1lAAEriDaUbZQPYHI5QE5nC7fVC-e7vISfS4-Or-IEg8GQ6F6fh0EAqIRQRQBXwouh8B7jFCvRTBIRgYzAYHkUHoKA6bCM5ms4xc3zI1FQO6C4QisU09AynAAen1UAAosY7MYnFkhGoDUaYMYGJBQKzzlB4ZYAORSzLZPwBIIhULSj1QVRQEB0VlIFQqeAMEBIVxBN3c+weJAQYDRKCu91QD39BjzFQe9q2qBEVwAK2A-FZKHg0VQUGQyxzIBQbZUa348EUbc8EYyICg9kGJiE8GAKleIRo+Z9EBD9Gn4cjGN2qlZBjdq09heLpZw7LodwJKE6pFe3
@silicakes
silicakes / dedupeSequence.js
Last active September 12, 2021 12:14
Dedupe consecutive sequences from an array
/*
This removes consecutive sequences from an array of characters.
See examples below + a working example @ https://jsfiddle.net/63v4pbq7/5/
*/
dedupeSequence = (seq) => {
let sequences = [];
// The longest sequence can be exacly half of the values
const maxLength = Math.floor(seq.length / 2);
const stringSequence = seq.join("");
@silicakes
silicakes / coc-settings.json
Created August 1, 2021 15:08
Adding DAML LSP support for coc.nvim - requires the DAML SDK
"languageserver": {
"daml": {
"command": "daml",
"args": ["damlc", "ide", "--RTS", "+RTS", "-M6G", "-N"],
"filetypes": ["daml"]
},
}
@silicakes
silicakes / extractAllNamedImports.sh
Last active January 21, 2020 15:03
Extracts and returns all named imports from JS import statements i.e the things inside {} when doing: import { foo, bar } from 'some-lib'
# Relies on ripgrep: https://github.com/BurntSushi/ripgrep
#
# Params:
# <library-name> a string with or without quotes
#
# Usage:
# $ ./extracAllNamedImports <library-name>
# Output
# $ ./getNamedImportsByLibrary.sh date-fns
@silicakes
silicakes / threading.js
Created January 22, 2019 13:41
clojure style threading macro example in js
// Threading macros, also known as arrow macros,
// convert nested function calls into a linear flow of function calls,
// improving readability. The idea is similar to 'pipelining'
const double = str => `${str} ${str}`;
const reverse = str => str.split("").reverse().join('');
const capitalize = str => str.charAt(0).toUpperCase() + str.slice(1);
const pad = (maxLength, chr = ' ') => str => str.toString().padEnd(maxLength, chr);
const thread = function thread(...args) {
@silicakes
silicakes / ClickTrigger.tsx
Created January 1, 2019 15:04
FramerX component interaction
import * as React from "react";
import { PropertyControls, ControlType } from "framer";
import { data } from "./Examples";
export class ClickTrigger extends React.Component<any> {
static propertyControls: PropertyControls = {
number: { type: ControlType.Number, defaultValue: 0 }
};
onClick = () => {
import * as React from "react";
import { PropertyControls, ControlType, Override } from "framer";
import { data } from "./Examples";
const style: React.CSSProperties = {
height: "100%",
display: "flex",
alignItems: "center",
justifyContent: "center",
textAlign: "center",
color: "#8855FF",
import * as React from "react";
import { render } from "react-dom";
import "./styles.css";
function App(props) {
return (
<div className="App">
<h1> {props.text}</h1>
</div>
import * as React from "react";
import { render } from "react-dom";
import "./styles.css";
function App(props) {
return (
<div className="App">
<h1> {props.text}</h1>
</div>