Skip to content

Instantly share code, notes, and snippets.

@jimbrig
jimbrig / titleUrlMarkdownClip.js
Created September 27, 2024 01:40 — forked from bradleybossard/titleUrlMarkdownClip.js
Bookmarklet to copy current page title and url in Markdown format to clipboard, like [title](url) - Usual for posting links to resources in README.md files
javascript:(function() {
function copyToClipboard(text) {
if (window.clipboardData && window.clipboardData.setData) {
/*IE specific code path to prevent textarea being shown while dialog is visible.*/
return clipboardData.setData("Text", text);
} else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
var textarea = document.createElement("textarea");
textarea.textContent = text;
@jimbrig
jimbrig / gist:eaf97bac73e9056c55d12a9023df2a4c
Created September 27, 2024 01:38 — forked from asabaylus/gist:3071099
Github Markdown Heading Anchors

Anchors in Markdown

To create an anchor to a heading in github flavored markdown. Add - characters between each word in the heading and wrap the value in parens (#some-markdown-heading) so your link should look like so:

[create an anchor](#anchors-in-markdown)

@jimbrig
jimbrig / convertImgToBase64.js
Created September 25, 2024 20:56 — forked from MarkoCen/convertImgToBase64.js
Read Image (PNG/JPEG) From Disk and Convert it to base64-encoded string on Node Server
import fs from 'fs';
import path from 'path';
const convert = (imgPath) => {
// read image file
fs.readFile(imgPath, (err, data)=>{
// error handle
if(err) {
throw err;
}
@jimbrig
jimbrig / bookmarkleting.md
Created September 25, 2024 19:45 — forked from caseywatts/bookmarkleting.md
Making Bookmarklets

This is one chapter of my "Chrome Extension Workshops" tutorial, see the rest here: https://gist.github.com/caseywatts/8eec8ff974dee9f3b247

Unrelated update: my book is out! Debugging Your Brain is an applied psychology / self-help book

Making Bookmarklets

I'm feeling very clever. I've got this sweet line of javascript that replaces "cloud" with "butt". My mom would LOVE this, but she doesn't computer very well. I'm afraid to show her the Developer Console and have her type/paste this in. But she IS pretty good at bookmarks, she knows just how to click those!

A bookmark normally takes you to a new web page. A bookmarklet is a bookmark that runs javascript on the current page instead of taking you to a new page. To declare that it is a bookmarklet, the "location" it points to starts with javascript:.

@jimbrig
jimbrig / .exec-shiny-app.R
Created September 24, 2024 00:06 — forked from dancingfrog/.exec-shiny-app.R
.exec-shiny-app.R
#!/usr/bin/env Rscript
# Title : Execute Shiny App
# Objective : Initialize Plumber and run Shiny app as "future" (background) worker as defined by local app.R or server.R/ui.R
# Created by: John Hall
library("future")
library("httr")
library("httpuv")
library("magrittr")
library("plumber")
library("shiny")
@jimbrig
jimbrig / jq-cheetsheet.md
Created September 21, 2024 00:05 — forked from olih/jq-cheetsheet.md
jq Cheet Sheet

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq

@jimbrig
jimbrig / ChatTTY.ps1
Created September 15, 2024 22:57 — forked from ShaunLawrie/ChatTTY.ps1
ChatTTY - A wireframe of a chat app in PwshSpectreConsole
#Requires -Modules @{ ModuleName = 'PwshSpectreConsole'; RequiredVersion = '2.1.1' }
Set-SpectreColors -AccentColor DeepPink1
# Build root layout scaffolding for:
# .--------------------------------.
# | Title | <- Update-TitleComponent will render the title
# |--------------------------------|
# | | <- Update-MessageListComponent will display the list of messages here
# | |
@jimbrig
jimbrig / PowerShellSingleFileScriptTemplate.ps1
Created August 30, 2024 14:59 — forked from deadlydog/PowerShellSingleFileScriptTemplate.ps1
PowerShell template for a single-file script
<#
.SYNOPSIS
PUT SHORT SCRIPT DESCRIPTION HERE AND ADD ANY ADDITIONAL KEYWORD SECTIONS AS NEEDED (.PARAMETER, .EXAMPLE, ETC.).
#>
[CmdletBinding()]
param (
# PUT PARAMETER DEFINITIONS HERE AND DELETE THIS COMMENT.
)
process {
@jimbrig
jimbrig / PowerShellUtilities.psm1
Created August 30, 2024 14:57 — forked from deadlydog/PowerShellUtilities.psm1
Powershell Invoke-ScriptBlockWithRetries function to execute arbitrary PowerShell code and automatically retry if an error occurs
function Invoke-ScriptBlockWithRetries {
[CmdletBinding(DefaultParameterSetName = 'RetryNonTerminatingErrors')]
param (
[Parameter(Mandatory = $true, HelpMessage = "The script block to execute.")]
[ValidateNotNull()]
[scriptblock] $ScriptBlock,
[Parameter(Mandatory = $false, HelpMessage = "The maximum number of times to attempt the script block when it returns an error.")]
[ValidateRange(1, [int]::MaxValue)]
[int] $MaxNumberOfAttempts = 5,
@jimbrig
jimbrig / Makefile
Created August 28, 2024 19:27 — forked from thierrymoudiki/Makefile
R package workflow (assuming you're on macOS or Linux)
.PHONY: buildsite check clean coverage docs getwd initialize install load render setwd start test usegit
.DEFAULT_GOAL := help
define BROWSER_PYSCRIPT
import os, webbrowser, sys
from urllib.request import pathname2url
# The input is expected to be the full HTML filename
filename = sys.argv[1]
filepath = os.path.abspath(os.path.join("./vignettes/", filename))