Skip to content

Instantly share code, notes, and snippets.

View jarrodek's full-sized avatar

Paweł Uchida-Psztyć jarrodek

View GitHub Profile
@jarrodek
jarrodek / big-int-parser.js
Last active November 30, 2021 23:02
Parsing a JSON that has a big integer value
/* This is the value that is being parsed. It is defined here because the `reviver` function need the access to it. */
const body = '[{"id":1110746394641760256,"name":"fc1"}]';
/**
* The reviver function passed as a second argument to the JSON.parse() function.
* It transforms the numbers that are above the max integer value into BigInt.
*
* Note 1, BigInt is not the same as a Number. In fact you cannot perform operations on the thwo types.
* Note 2, This won't work when the stringified object has multiple number values that are similar
* (the first 10+ digits are the same, depnding on the value of the `Number.MAX_SAFE_INTEGE`).
@jarrodek
jarrodek / commit.js
Created November 9, 2019 02:18
This gist demonstrates how to use nodegit to sign commits using GPG keys.
const nodegit = require('nodegit');
const path = require('path');
const fs = require('fs-extra');
const openpgp = require('openpgp');
const fileName = 'newfile.txt';
const fileContent = 'hello world';
const directoryName = 'salad/toast/strangerinastrangeland/theresnowaythisexists';
/**
* This example creates a certain file `newfile.txt`, adds it to the git
@jarrodek
jarrodek / a11y-suite.js
Created June 23, 2019 01:29
open-wc - accessability test plugin
import { fixture } from '@open-wc/testing';
/* global Mocha, axs */
const Test = Mocha.Test;
const Suite = Mocha.Suite;
export default async (id, html, ignoredRules) => {
const element = await fixture(html);
const mInstancwe = new Mocha();
const suiteInstance = Suite.create(mocha.suite, 'A11y Audit: ' + id);
const axsConfig = new axs.AuditConfiguration();
@jarrodek
jarrodek / webcomponentsjs-error.html
Created December 27, 2018 11:58
A description of the issue for webcomponentsjs library
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes">
<title>Issue reproduction</title>
<script src="../../webcomponentsjs/webcomponents-loader.js"></script>
<style>
html,
body {
const builder = require('api-console-builder');
builder({
dest: 'build',
// noOptimization: true,
embedded: true,
verbose: true,
raml: 'api.raml'
})
.then(() => console.log('Build complete'))
@jarrodek
jarrodek / apic-build-fragments.js
Created June 18, 2018 18:53
An example of building the API console with api-console-builder
const builder = require('api-console-builder');
builder({
tagName: '5.0.0-preview',
embedded: true,
themeFile: './my-theme.html',
destination: 'console-bundle'
})
.then(() => console.log('Build complete <3'))
.catch((cause) => console.log('Build error <\\3', cause.message));
@jarrodek
jarrodek / api-console-styles.html
Created August 8, 2017 17:00
API console styles example
<style is="custom-style">
:root {
--arc-color-primary: pink; /* overrides: --primary-color: var(--arc-color-primary, #00a2df); */
--arc-font-family: Verdana; /* overrides: --arc-font-common-base and therefore all fonts definitions */
--arc-request-panel: {
/* Applied to whole reqiuest panel, after applying default styling that can be changed here */
margin-bottom: 120px;
}
@jarrodek
jarrodek / affirmation
Created May 30, 2017 13:42
MuleSoft Contributor Agreement Acceptance by Pawel Psztyc
I, Pawel Psztyc, have read and do accept the MuleSoft Contributor Agreement
at http://www.mulesoft.org/legal/contributor-agreement.html
Accepted on Tue May 30 2017 14:42:45 GMT+0100 (BST)
@jarrodek
jarrodek / atom-beautify-debug-output.md
Last active May 26, 2017 16:32
atom beautify debug output
@jarrodek
jarrodek / polymer-import-location.js
Created March 9, 2017 11:28
A script that recognizes Polymer element's URL and parses it to read location of assets like web workers to import during runtime.
var importLocation = '';
(function() {
var url;
if (window.currentImport && window.currentImport.URL) {
url = window.currentImport.URL;
if (window.currentImport._URL) {
url = window.currentImport._URL;
}
} else if (window.currentImport._URL) {
url = window.currentImport._URL;