Skip to content

Instantly share code, notes, and snippets.

View agoldis's full-sized avatar
🎯
Focused

Andrew Goldis agoldis

🎯
Focused
View GitHub Profile
@agoldis
agoldis / deriveStateSelectors.js
Created April 28, 2018 23:41
redux - full example
import { compose } from "redux";
import { createSelector } from "reselect";
const getBooks = state => state.books;
const getUsers = state => state.users;
const getComments = state => state.comments;
const usersSummary = createSelector(
[getUsers, getComments],
(users, comments) =>
@agoldis
agoldis / deriveState.js
Created April 29, 2018 00:14
redux - use state object
import {
booksSummarySelector,
usersSummarySelector,
userDetailsSelector,
bookDetailsSelector
} from "./selectors";
class NotRealState {
constructor(state) {
Object.defineProperty(this, "_state", {
User types "a" User types "b" Client's value is "ab"
^
+----------------------------+------------------------------------------------------------------------------>
+ + |
|
+--------------------------+ +--------------------------+ |
debounce rate | debounce rate | |
| | |
| | +
v v this.isSaving = false
#!/bin/sh
dateDir=`date +%Y-%m-%d-%H-%M`
baseDir="/tmp/$dateDir"
mkdir -p $baseDir
for specName in `find ./cypress/integration/ -type f -printf "%f\n"`; do
rm -rf ./test-results/mochawesome
workDir=$baseDir/$specName
@agoldis
agoldis / invoice.html
Created July 22, 2019 18:13
Text cut in half Chromium issue
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1, user-scalable=yes" />
<title>Invoice INV0002</title>
<!-- Fonts loading -->
<link
href="https://fonts.googleapis.com/css?family=Open+Sans:400,600&display=swap"
rel="stylesheet"
@agoldis
agoldis / setGithubRegistry.sh
Created October 16, 2019 17:47
Define credentials to private Github registry
#!/bin/sh
DIRECTORY=$(cd `dirname $0` && pwd)
cd $DIRECTORY/..
echo "Adding GitHub registry credentials to $DIRECTORY/../.npmrc"
echo "\n//npm.pkg.github.com/:_authToken=$GITHUB_SECRET" >> .npmrc
@agoldis
agoldis / delete-github-package.graphql
Created October 25, 2019 05:26
Github - delete private package
# get version id
query($name: String!, $owner: String!) {
repository(name: $name, owner: $owner) {
id
name
registryPackages(first: 10) {
nodes {
versions(first: 10) {
nodes{
id
@agoldis
agoldis / mergeHTML.js
Last active September 18, 2020 07:47
Load modern and legacy scripts. Add multiple webpack targets into a single html file. html-webpack-plugin does not support merging multiple webpack targets. This naive and simple solution generates 2 html files and merges script tag into index.html.
#!/usr/bin/env node
const { readFileSync, writeFileSync } = require('fs');
const { parse } = require('node-html-parser');
const { resolve } = require('path');
const modernPath = resolve(__dirname, '..', 'dist', 'modern.html');
const legacyPath = resolve(__dirname, '..', 'dist', 'legacy.html');
const outputPath = resolve(__dirname, '..', 'dist', 'index.html');
@agoldis
agoldis / gist:be00343afe0fc5f9130c01f3cd914f5b
Created October 15, 2020 21:33
my 5 months daughter first lines of code
j,........D"      ≈xc≥≥≥≥≥
)
hguhv m hgfcr4frdfvfv); j,........D"≥≥≥≥≥
); j,........D"≥≥≥≥≥
); j,........D"≥≥≥≥≥
@agoldis
agoldis / parse-git-url.ts
Last active July 31, 2021 08:11
Inline git-url-parse with Safari support, w/o normalize-url
// @ts-ignore
import isSsh from 'is-ssh';
// @ts-ignore
import parsePath from 'parse-path';
export function gitUrlParse(url: string) {
if (typeof url !== 'string') {
throw new Error('The url must be a string.');
}