Skip to content

Instantly share code, notes, and snippets.

Avatar

Jeswin jeswin

View GitHub Profile
View create-jwt-rs256.sh
basho \
--import fs fs \
--import crypto crypto \
-d header '{ "alg": "RS256", "type": "JWT" }' \
-d payload '{ "sub": "alice", "iss": "example.com", "iat": Date.now() }' \
-d toBase64 'x => Buffer.from(JSON.stringify(x)).toString("base64")' \
-d toBase64Url 'x => x.replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_")' \
-d base64Header 'k.toBase64Url(k.toBase64(k.header))' \
-d base64Payload 'k.toBase64Url(k.toBase64(k.payload))' \
-d privateKey 'fs.readFileSync(process.cwd() + "/privatekey.pem", "utf8")' \
@jeswin
jeswin / Export each as SVG.js
Created Mar 18, 2021 — forked from vieron/Export each as SVG.js
Export each as SVG. Modified some lines from the original by Aaron Beall (http://fireworks.abeall.com/extensions/commands/Export/Export%20SVG.jsf) to export each selected object as a separate SVG file.
View Export each as SVG.js
// Fireworks JavaScript Command
// Exports current document state as SVG graphics format
// Install by copying to Fireworks/Configuration/Commands/
// Run via the Commands menu in Fireworks
// Aaron Beall 2010-2011
// Version
var VERSION = "0.6.1";
// Params
@jeswin
jeswin / update-npm-deps.sh
Created Feb 11, 2021
Update npm dependencies in package.json to latest version
View update-npm-deps.sh
basho --import './package.json' pack -j pack -j 'Object.keys(x.dependencies)' -m x -e 'npm install ${x}@latest'
@jeswin
jeswin / calicutshop-topframe.js
Created Jan 19, 2021
calicutshop-topframe.js
View calicutshop-topframe.js
// Copyright Pristine Initiatives, 2000. No part of this may be -
// copied without written consent from Pristine Initiatives.
// Please send all bug reports, comments to jeswin@eudoramail.com
// upd : 12/27/00 m/d/y
//globals
/*
todo :
imp >> on uploading change the root to / instead of CalicutShop/ : done
*/
@jeswin
jeswin / package-exact.js
Last active Dec 9, 2020 — forked from kentcdodds/package-exact.js
make your package.json dependencies be the exact version that's in your node_modules currently
View package-exact.js
/* jshint node:true */
/* eslint-env node */
/*
* This will look at the current version of all of your dependencies and update your package.json
* with the specific version that you currently have in node_modules. This will save you from the
* sadness that is: DEPENDENCY MANAGEMENT
*
* Place this file in a folder that's a a sibling to your package.json and node_modules
* Then simply run: node scripts/package-strict
@jeswin
jeswin / router-article.full.html
Last active Jan 24, 2020
router-article-full
View router-article.full.html
<html>
<head>
<script
src="https://unpkg.com/react@16/umd/react.development.js"
crossorigin
></script>
<script
src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"
crossorigin
></script>
@jeswin
jeswin / router-article-todos.js
Last active Feb 9, 2019
router-article-todos
View router-article-todos.js
const TodoList = ({ todos, pathArr }) => {
const [first, todoId] = pathArr;
return (
<div>
<h1>Todos Module</h1>
{typeof todoId === "undefined" ? (
<div>
<h2>List of todos:</h2>
{todos ? (
todos.map(todo => <Todo key={todo.id} todo={todo} />)
@jeswin
jeswin / router-article-popstate.js
Last active Feb 9, 2019
router-article-popstate
View router-article-popstate.js
window.onpopstate = ev =>
storePathInState(window.location.pathname.split("/").slice(1));
@jeswin
jeswin / router-article-click-handler.js
Last active Feb 9, 2019
router-article-click-handler
View router-article-click-handler.js
function createClickHandler(url) {
return ev => {
history.pushState({}, undefined, url);
storePathInState(url.split("/").slice(1));
ev.preventDefault();
};
}
@jeswin
jeswin / router-article-home-component.js
Last active Feb 9, 2019
router-article-home-component
View router-article-home-component.js
const Home = ({ pathArr }) => {
const [pathInState, setPathFn] = useState(pathArr);
storePathInState = setPathFn;
return pathInState[0] === "todos" ? (
// If the first part of the url is /todos, show the TodoList component
<TodoList todos={todos} pathArr={pathInState} />
) : pathInState[0] === "about" ? (
// If the first part of the url is /todos, show the TodoList component
<About />