Skip to content

Instantly share code, notes, and snippets.

View joelpalmer's full-sized avatar
🐍

Joel Palmer joelpalmer

🐍
View GitHub Profile
@joelpalmer
joelpalmer / update_neovim.zsh
Last active December 21, 2022 08:16
Update, Build and Install Neovim
# Update Neovim to latest from master
# https://github.com/neovim/neovim/commits/master
# You should have the Neovim repo cloned
upnvim() {
cd ~/vim-dev/sources/neovim # change to your local repo
git pull
make distclean
make CMAKE_BUILD_TYPE=RelWithDebInfo -j4 # Fast with Debug info. Not quite Release fast.
sleep 10 # You don't need this but I have my reasons :-)
sudo make install
@joelpalmer
joelpalmer / lib.rs
Created February 9, 2022 15:13
Balanced Binary Tree in Rust
use std::collections::VecDeque;
#[derive(Debug, PartialEq)]
pub struct BinaryTree<T> {
pub value: T,
pub left: Option<Box<BinaryTree<T>>>,
pub right: Option<Box<BinaryTree<T>>>,
}
impl<T> BinaryTree<T>
@joelpalmer
joelpalmer / markdown.lua
Created October 12, 2021 13:35
An after/ftplugin for buffer-scoped nvim-cmp configuration
-- Setup cmp setup buffer configuration - 👻 text off for markdown
local cmp = require "cmp"
cmp.setup.buffer {
sources = {
{ name = "vsnip" },
{ name = "spell" },
{
name = "buffer",
opts = {
get_bufnrs = function()
@joelpalmer
joelpalmer / completion.lua
Last active October 12, 2021 13:37
nvim-cmp config with Lua (completion/init.lua) using lspkind
-- Setup nvim-cmp
local cmp = require "cmp"
local lspkind = require "lspkind"
cmp.setup {
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
@joelpalmer
joelpalmer / activate-browser-tab.applescript
Created May 3, 2021 19:04
Activate a browser tab via title text
on run argv
tell application "Brave Browser"
repeat with w in (windows)
set j to 0
repeat with t in (tabs of w)
set j to j + 1
if title of t contains (item 1 of argv) then
set (active tab index of w) to j
return
end if
@joelpalmer
joelpalmer / init.lua
Last active December 10, 2022 04:01
neovim config (Lua)
-- *** Neovim Config Luatized *** --
require("joel.plugins")
-- treesitter & lsp
require("joel.config")
-- telescope
require("joel.telescope")
-- mappings, options, globals
@joelpalmer
joelpalmer / life-changing-aliases.zsh
Last active August 30, 2022 20:20
Life changing Zsh aliases
# Custom Aliases
alias -s txt=nvim
alias -s vim=nvim
alias -s zsh=nvim
alias -s zshrc=nvim
alias -s {c,h}=nvim
alias -s {js,json}=nvim
alias -s {md,MD}=nvim
alias -s {rs,toml}=nvim
alias -s {yml}=nvim
@joelpalmer
joelpalmer / life-changing-funcs.zsh
Last active December 17, 2023 09:22
Zsh functions that change lives
#look up synonym - (word)
# slow and buggy
syn() {
curl -s "https://api.dictionaryapi.dev/api/v2/entries/en/$1" | jq '.[].meanings[].definitions[].synonyms[]'
}
# zd - use zoxide & FZF to find and go to directory
# Not sure why zoxide query -i with FZF doesn't CD
zd() {
local dir
@joelpalmer
joelpalmer / index.js
Created July 18, 2019 13:22
Array.prototype.swap
if (!Array.prototype.swap) {
Object.defineProperty(Array.prototype, 'swap', {
value: function (idxA, idxB) {
if (this == null) {
throw new TypeError('"this" is null or not defined');
}
const o = Object(this);
const len = o.length >>> 0;
if (len === 0) {
@joelpalmer
joelpalmer / merge2sortedArrays.js
Created April 27, 2017 20:42
Merge 2 sorted arrays
const data = {
items: [[{
name: "Joel",
location: "Texas",
Sport: "Running",
Id: 5
},
{
name: "Michelle",
location: "California",