Skip to content

Instantly share code, notes, and snippets.

View jeswin's full-sized avatar

Jeswin jeswin

View GitHub Profile
@jeswin
jeswin / create-jwt-rs256.sh
Last active May 8, 2021 07:44
Create a JWT
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 March 18, 2021 13:21 — 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.
// 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 February 11, 2021 07:36
Update npm dependencies in package.json to latest version
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 January 19, 2021 11:28
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 December 9, 2020 02:02 — forked from kentcdodds/package-exact.js
make your package.json dependencies be the exact version that's in your node_modules currently
/* 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 January 24, 2020 13:39
router-article-full
<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 February 9, 2019 11:20
router-article-todos
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 February 9, 2019 11:03
router-article-popstate
window.onpopstate = ev =>
storePathInState(window.location.pathname.split("/").slice(1));
@jeswin
jeswin / router-article-click-handler.js
Last active February 9, 2019 11:02
router-article-click-handler
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 February 9, 2019 11:16
router-article-home-component
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 />