Skip to content

Instantly share code, notes, and snippets.

View Jay-Madden's full-sized avatar

Jay Madden Jay-Madden

View GitHub Profile
local function wrap_golang_return()
if vim.bo.filetype ~= "go" then
return
end
local query_str = [[
(_
result: (_) @result
(ERROR)? @error
)
@Jay-Madden
Jay-Madden / wrap_golang_multiline_return.lua
Last active July 24, 2024 04:04
Quick and dirty neovim autocmd to add or remove the wrapping parenthesis around golang multi returns whenever they go from single return to multireturn
local function wrap_golang_multi_return()
-- If its not a go buffer dont bother doing any more work
if vim.bo.filetype ~= "go" then
return
end
local cursor_pos = vim.api.nvim_win_get_cursor(0)
local line_num, line_col = cursor_pos[1], cursor_pos[2]
local curr_buf = vim.api.nvim_get_current_buf()
@Jay-Madden
Jay-Madden / onefetch.sh
Last active August 17, 2023 12:36
Bash script to display onefetch every time you navigate locally to a new repository
# Call onefetch if we navigate to a new repository
LAST_REPO=""
cd() {
builtin cd "$@";
git rev-parse 2>/dev/null;
if [ $? -eq 0 ]; then
if [ "$LAST_REPO" != $(basename $(git rev-parse --show-toplevel)) ]; then
onefetch
LAST_REPO=$(basename $(git rev-parse --show-toplevel))
@Jay-Madden
Jay-Madden / TruncateTableAsync.cs
Created May 19, 2022 18:14
Extension method to truncate a postgres table from an ef context
public static async Task TruncateTable<T>(this CersPg context) where T : class
{
var tableAttr = (TableAttribute)Attribute.GetCustomAttribute(typeof(T), typeof(TableAttribute));
var sql = $"TRUNCATE {tableAttr.Name} RESTART IDENTITY CASCADE";
await context.Database.ExecuteSqlRawAsync(sql);
}
public static class LinqExtensions
{
public static IQueryable<T> QueryIfElse<T>(this IQueryable<T> query,
Func<bool> predicate,
Func<IQueryable<T>, IQueryable<T>> @if,
Func<IQueryable<T>, IQueryable<T>> @else) =>
predicate() ? @if(query) : @else(query);
}
"Vundle
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
"Plugin 'Valloric/YouCompleteMe'
"Plugin 'Valloric/iCompleteMe'
Plugin 'scrooloose/nerdtree'
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace TestApp
{
internal class Stuff
{