Skip to content

Instantly share code, notes, and snippets.

View remarkablemark's full-sized avatar

Mark remarkablemark

View GitHub Profile
Run git push heroku master
git push heroku master
shell: /usr/bin/bash -e {0}
remote:
remote: ! Push rejected, source repository is a shallow clone. Unshallow it with `git fetch --all --unshallow` and try pushing again.
remote:
To https://git.heroku.com/***.git
! [remote rejected] master -> master (shallow update not allowed)
error: failed to push some refs to 'https://git.heroku.com/***.git'
Error: Process completed with exit code 1.
jobs:
custom-deploy:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Heroku login credentials
run: |
jobs:
heroku-deploy:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Deploy to Heroku
uses: akhileshns/heroku-deploy@v3.12.12
with:
heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
/**
* Evaluate XPath expression.
*
* @param {string} xpathExpression - XPath expression.
* @param {HTMLElement} [contextNode=document] - Context node for the query.
* @returns {HTMLElement[]}
*/
function evaluateXPath(xpathExpression, contextNode = document) {
const result = document.evaluate(
xpathExpression,
@remarkablemark
remarkablemark / dispatch-keydown-event.js
Created November 16, 2022 23:31
JavaScript dispatch keydown event programmatically
const KEY_CODE = {
ARROW_DOWN: 40,
BACKSPACE: 8,
ENTER: 13,
};
/**
* Dispatch keydown event.
*
* @param {number} keyCode
const { createHash } = require('crypto');
function hash(string) {
return createHash('sha256').update(string).digest('hex');
}
@remarkablemark
remarkablemark / stripe-php-exceptions.md
Created October 11, 2022 14:58
Stripe PHP exceptions
Description Exception
Decline \Stripe\Exception\CardException
Too many requests made to the API too quickly \Stripe\Exception\RateLimitException
Invalid parameters were supplied to Stripe's API \Stripe\Exception\InvalidRequestException
Authentication with Stripe's API failed \Stripe\Exception\AuthenticationException
Network communication with Stripe failed \Stripe\Exception\ApiConnectionException
Display a very generic error to the user \Stripe\Exception\ApiErrorException
async function hash(string) {
const utf8 = new TextEncoder().encode(string);
const hashBuffer = await crypto.subtle.digest('SHA-256', utf8);
const hashArray = Array.from(new Uint8Array(hashBuffer));
const hashHex = hashArray
.map((bytes) => bytes.toString(16).padStart(2, '0'))
.join('');
return hashHex;
}

Set up Python 2 on macOS

Install pyenv:

brew install pyenv

Create symbolic link:

@remarkablemark
remarkablemark / spy-resize-event.test.js
Created June 13, 2018 19:20
How to spy on window resize event in test.
const spy = jest.fn(); // or `jasmine.createSpy()`
const testWidth = 420;
beforeAll(() => {
window.addEventListener('resize', spy);
});
it('does not fire resize event by default', () => {
expect(spy).not.toHaveBeenCalled();
expect(window.innerWidth).not.toBe(testWidth);