Skip to content

Instantly share code, notes, and snippets.

View gildniy's full-sized avatar
🌏
Remote

Gildas Niyigena gildniy

🌏
Remote
View GitHub Profile
@gildniy
gildniy / (node:19200) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
Created December 17, 2018 23:45
This is the error am getting after updating my Capacitor Ionic project to Angular 6
"C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" run start --scripts-prepend-node-path=auto
> [email protected] start C:\Users\KiraMed\Documents\COURSES\heedd-admin
> run-p pug-it:w server
> [email protected] pug-it:w C:\Users\KiraMed\Documents\COURSES\heedd-admin
> pug src -P -w
@gildniy
gildniy / random-hex-color.ts
Last active March 1, 2019 22:29
Generate random Hex Color string value in Javascript
randomHexColor:string = () => `#${(Math.random()*0xFFFFFF<<0).toString(16)}`;
@gildniy
gildniy / test.spec.jsx
Last active October 31, 2019 11:13
Testing a React Functional Component using Enzyme
import React from 'react';
import {shallow} from "enzyme";
const numbersArr = ["One", "Two", "Three"];
const Count123array = () => (
<div className="my-text">
{numbersArr[1]}
</div>
);
@gildniy
gildniy / RecipeItem.js
Created January 15, 2020 21:20 — forked from pylnata/RecipeItem.js
Jest+Enzyme example unit test with SHALLOW for React component using useEffect and (useDispatch, useSelector) hooks
import React from "react";
export const Recipeitem = (props) => {
return (<div>
{props.title}
</div>)
}
@gildniy
gildniy / setTimeOut.test.js
Created June 23, 2020 11:28
Why setTimeOut is not always a good option?
// https://jj09.net/settimeout-considered-harmful/
// NO TIMEOUT
let someVar1 = 0;
const changeVar1 = () => {
someVar1 = 10;
return someVar1;
};
@gildniy
gildniy / index.md
Created June 26, 2020 05:10 — forked from mathisonian/index.md
requiring npm modules in the browser console

demo gif

The final result: require() any module on npm in your browser console with browserify

This article is written to explain how the above gif works in the chrome (and other) browser consoles. A quick disclaimer: this whole thing is a huge hack, it shouldn't be used for anything seriously, and there are probably much better ways of accomplishing the same.

Update: There are much better ways of accomplishing the same, and the script has been updated to use a much simpler method pulling directly from browserify-cdn. See this thread for details: mathisonian/requirify#5

inspiration

@gildniy
gildniy / delay.js
Created July 14, 2020 18:53 — forked from eteeselink/delay.js
ES7 async/await version of setTimeout
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
async function something() {
console.log("this might take some time....");
await delay(5000);
console.log("done!")
}
something();
@gildniy
gildniy / nodeAsyncTest.js
Created July 14, 2020 18:54 — forked from aescarcha/nodeAsyncTest.js
Javascript async / await resolving promises at the same time test
// Simple gist to test parallel promise resolution when using async / await
function promiseWait(time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(true);
}, time);
});
}
Enterprise: NJVYC-BMHX2-G77MM-4XJMR-6Q8QF
Professional: KBJFW-NXHK6-W4WJM-CRMQB-G3CDH
Keys are generic ones. These are the same from MSDN account.
Product Key : -6Q8QF
Validity : Valid
Product ID : 00369-90000-00000-AA703
Advanced ID : XXXXX-03699-000-000000-00-1032-9200.0000-0672017
@gildniy
gildniy / dynamodb_batch_delete.js
Created September 9, 2020 23:16 — forked from rproenca/dynamodb_batch_delete.js
Delete multiple items in a DynamoDB table
const AWS = require('aws-sdk');
const {parallelScan} = require('@shelf/dynamodb-parallel-scan');
const TABLE_NAME = '[table-name]';
const PRIMARY_PARTITION_KEY = '[partition-key]';
async function fetchAll() {
const CONCURRENCY = 250;
const alias = `#${PRIMARY_PARTITION_KEY}`;
const name = PRIMARY_PARTITION_KEY;