Skip to content

Instantly share code, notes, and snippets.

View vidurb's full-sized avatar
💉

Vidur B vidurb

💉
View GitHub Profile
@vidurb
vidurb / names.json
Last active January 26, 2023 09:42
[
{
"name": "ardent",
"description": "A cruiser destroyed while attempting to aid the stricken Rebel Nebulon-B Frigate Inamo."
},
{
"name": "independence",
"description": "Cruiser in X-Wing computer game, served as the Calamarian flagship at around the time of the Battle of Yavin."
},
{
@vidurb
vidurb / set-locked-versions.fish
Created September 29, 2021 09:54
Set versions in package.json to currently locked version (Yarn v2 only)
for package in (cat package.json | jq -rc '.dependencies | to_entries | .[]')
set _package (echo "$package" | jq -r '.key')
set _version (echo "$package" | jq -r '.value')
if test '^' = (string sub --length 1 $_version)
set _installed_version (yarn info $_package --json | jq -rc '.children.Version')
cat package.json | jq --arg pname "$_package" --arg nver "$_installed_version" '.dependencies."\($pname)" = $nver' > package.json.new
mv -f package.json.new package.json
end
end
@vidurb
vidurb / jsdoc-regex
Created June 23, 2021 11:24
Convert apidoc comments to those suitable for swagger-jsdoc
Regex: \/\*\*\s?\n\s+\*\s+@api\s+\{(\w+)\}\s+([a-zA-Z/:\-_]+)\s+([\w ]+)\n\s?\*\s?@apiName\s+([a-zA-Z]*)\n\s?\*\s+@apiGroup\s+([a-zA-Z]*)
Replacement:
/**
* @openapi
* $2:
* $1:
* operationId: $4
* description: $3
* tags:
* - $5
---
package_update: true
runcmd:
-
- snap
- remove
- oracle-cloud-agent
-
- apt
- purge
@vidurb
vidurb / barrier_karabiner.lua
Last active April 29, 2021 06:00 — forked from knu/barrier_karabiner.lua
Barrier and Karabiner-Elements integration using Hammerspoon
knu = require("knu") -- https://github.com/knu/hs-knu
-- Switch between Karabiner-Elements profiles as Barrier enters a different host
do
-- Configure Barrier (https://github.com/debauchee/barrier) to output log to ~/Library/Logs/barrier.log
local logFile = os.getenv("HOME") .. "/Library/Logs/barrier.log"
local lineNo = 1
local host = nil
local defaultProfile = "Vidur's Profile"
local profileForHost = function (host)
@vidurb
vidurb / bootstrapLinux.sh
Created August 3, 2020 12:20
Terminal bootstrap scripts
echo test
@vidurb
vidurb / fontloader.js
Last active May 1, 2019 06:11 — forked from rungta/fontloader.js
Load CSS `@font-face` fonts by listening for font loading events. A workaround while we wait for browsers to support the `font-rendering: swap` property.
/**
* fontloader.js
Helps you avoid FOIT and progressively load in multiple
sets of webfonts as asynchronous non-blocking resources.
Apply them on the page when the fonts are ready, like so:
.title-type { font-family: serif; }
.prose-type { font-family: sans-serif; }
@vidurb
vidurb / checkbox-utility.js
Last active February 21, 2019 10:04
A JS function to enable keypress events of choice on input labels.
/**
* Function inputLabelTrigger
* Default Functionality: Adds an event handler for input labels that triggers the
* input linked to the label with a 'click' event when the label has focus and receives
* a keypress with 'return' or 'spacebar' keycodes.
* If tabIndex is false, the tabIndex for labels will not be set to 0 to allow them to
* receive keyboard focus. Labels can be manually made focusable by adding 'tabindex=0'
* to them in HTML/DOM.
* If keycode is false, the return and spacebar keycodes are used by default. If a valid
* keyCode is passed, that will be used as the impetus to trigger the input.