Skip to content

Instantly share code, notes, and snippets.

View rvisharma's full-sized avatar
:shipit:

Ravi Sharma rvisharma

:shipit:
View GitHub Profile
@rvisharma
rvisharma / typewriter-override.css
Created January 23, 2022 12:21
Obsidian Snippets
/****
Adds h1,h2...h6 before the heading in live preview (editor) mode
Works well in typewriter theme as it does not change heading height in live preview mode, may work for other themes as well
****/
.HyperMD-header.cm-line {
position: relative;
}
// Name: Site Counter rvi.fyi
// Author: rvisharma
// Description: Get latest site visits for rvi.fyi
// Twitter: @life_of_rvi
import '@johnlindquist/kit'
let { entries, write } = await db({ entries: [] })
onTab('Visits', async () => {
// Menu: Decode JWT
// Description: Enter any string which contains valid jwt.
// Author: Ravi Sharma
// Twitter: @irvisharma
/** @type typeof import("jsonwebtoken") */
const jwt = await npm('jsonwebtoken');
try {
const dirtyEncodedToken = await arg('Paste token here', generateLiveHint);
@rvisharma
rvisharma / surfingkeys-settings.js
Last active February 21, 2021 14:45
Surfing keys Config
// an example to create a new mapping `ctrl-y`
mapkey('<Ctrl-y>', 'Show me the money', function() {
Front.showPopup('a well-known phrase uttered by characters in the 1996 film Jerry Maguire (Escape to close).');
});
// disable emojis
iunmap(":");
// an example to replace `T` with `gt`, click `Default mappings` to see how `T` works.
map('gt', 'T');
@rvisharma
rvisharma / observable.js
Last active June 18, 2020 17:31
Observable from scratch
console.clear();
function createSafeObserver(unsafeObserver) {
let isDone = false;
const safeObserver = {
next: v => {
if (isDone) return;
unsafeObserver.next(v);
function parseLogs() {
// Write your code here.
return logs
// filter logs by method as POST and route as /create
.filter(eachLog => eachLog.includes('POST') && eachLog.includes('/create'))
// split the log and get the stringified object by index
.map(eachLog => eachLog.split('::')[3])
// parse them to object
.map(eachLog => JSON.parse(eachLog))
// filter by orders of Donuts (reduntant if filtering done along with Method filtering 'POST')
@rvisharma
rvisharma / rvi-iterm-scheme.json
Created October 2, 2019 06:06
custom iterm scheme
{
"Thin Strokes" : 4,
"Working Directory" : "\/Users\/ravi",
"Prompt Before Closing 2" : 0,
"Selected Text Color" : {
"Red Component" : 0,
"Color Space" : "sRGB",
"Blue Component" : 0,
"Alpha Component" : 1,
"Green Component" : 0
@rvisharma
rvisharma / docker.js
Last active August 31, 2019 14:17
docker pull save cron
function cloneScriptsRepo() {
// this function pulls the git repo (Scripts repo)
// return a promise and resolve it when git pull is completed
}
function getAllImages() {
// this function traverses the git repo (yaml files in /docker)
// parses all *.yaml files and returns list of docker images
}
@rvisharma
rvisharma / takeN.js
Last active January 31, 2019 05:13
Generator function katas
describe('generator functions', function(){
it('should yield first 3 values using generator', () => {
// As part of this test, create a generator function `take` which
// accepts the count and an array, and yields values from
// array till the count reaches.
const iterator = take(3, ['A','B','C','D','E']);
// Do not modify any assertions
assert.equal(iterator.next().value, 'A')
@rvisharma
rvisharma / cloudSettings
Last active October 5, 2019 10:15
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-10-05T10:15:41.992Z","extensionVersion":"v3.2.9"}