Skip to content

Instantly share code, notes, and snippets.

JQ

Get the ndjson data from the URL, use paste to concatenate the lines into a single line with commas, wrap it in square brackets to make it a valid JSON array, and then use jq to group the reviews by their review_source.

curl -s "https://raw.githubusercontent.com/ankit-lilly/testdata/f978a3ab71174e6e85beb56e1eaaffa7495cd4db/alexa.json" | paste -sd "," - | awk 'BEGIN {print "["} {print $0} END {print "]"}' | jq '
  reduce .[] as $i (
    {};
 .[$i.review_source] += [$i]

Create gist from currently open buffer :

%!tee /dev/stderr | gh gist create -f test.md --public -

Run the code in the current buffer and append the output below the file

%!tee /dev/stderr | node % | awk 'BEGIN {print "/*"} {print} END {print "*/"}'
#!/usr/bin/env ruby
require 'json'
require 'optparse'
require 'open3'
require 'time'
require 'thread'
# Default values
DEFAULT_AWS_PROFILE = 'accdev'
@ankit-lilly
ankit-lilly / setupvim.sh
Last active May 31, 2024 14:55
Shell command to setup my basic .vimrc
#!/bin/bash
# Backup existing .vimrc file
if [ -f "$HOME/.vimrc" ]; then
echo "Backing up existing .vimrc to .vimrc.backup"
mv "$HOME/.vimrc" "$HOME/.vimrc.backup"
fi
# Install vim-plug for plugin management
if [ ! -f "$HOME/.vim/autoload/plug.vim" ]; then