Skip to content

Instantly share code, notes, and snippets.

View emyann's full-sized avatar
🏠
Working from home

Yann RENAUDIN emyann

🏠
Working from home
View GitHub Profile
const glob = require('glob');
const util = require('util');
const fs = require('fs');
const path = require('path');
// icons.js
const icons= [
'account',
'plus'
];
function monitoredScope(fn: Function, ...args: any[]) {
const startTime = performance.now();
const result = fn.call(this, ...args);
const endTime = performance.now();
const elapsedTime = Math.round((endTime - startTime) * 1000) / 1000;
return { data: result, infos: { startTime, endTime, elapsedTime } };
}
@emyann
emyann / Icon.js
Last active September 28, 2018 19:39
MDI Icon support in React with Webpack
import { PureComponent, Component } from 'react'
import SVGInline from 'react-svg-inline'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import AppIcons from '../../../static/icons/app-icons.json'
const IconSVGContainer = styled.span`
display: inline-flex;
`
const IconSVG = styled(SVGInline)`
@emyann
emyann / singleton.es6.js
Created January 17, 2018 19:26
ES6 Singleton
class ImmutableClass {
constructor() {
// return value from class constructor
return createInstance()
}
}
let instance = null;
function createInstance() {
@emyann
emyann / cloudSettings
Last active May 10, 2019 14:55
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-05-10T14:55:05.821Z","extensionVersion":"v3.2.9"}
@emyann
emyann / AutoMapper.js
Last active September 27, 2016 06:42
AutoMapper.js with predicate applying
function DataMapper(schema, items) {
let _schema = _.clone(schema);
let transformer = (items) => {
return _.chain(items)
.map((obj) => {
return _.mapValues(_schema, (transformation) => {
if(!_.isObject(transformation)){
return _.get(obj, transformation);
}
else if(_.isFunction(transformation)){
var nbrReg = /(\d+(?:\.\d+)?)([a-z])?/i
var filtered = _.filter(document.querySelectorAll('.follow-item'),(i)=> { let followers = $(i).find('.item-info .item-info__subdetail .stat .stat__container').eq(1).find('.stat__number').text();let dataReg = nbrReg.exec(followers); return (dataReg[1] * ( dataReg[2] == 'k' ? 1000 :( dataReg[2]=='m'? 1000000 : 1) )) > 1000})
<#
.SYNOPSIS
Pretty description of what the script do
.EXAMPLE
PS C:\> .\Script-Boilerplate.ps1 -Option "Value"
.EXAMPLE
$var = @{}
PS C:\> .\Script-Boilerplate.ps1 -Option "Value" -OtherOption $var
#>
[CmdletBinding()]
@emyann
emyann / DataMapper.ts
Last active August 5, 2016 04:44
This curried function return a function that allows to transform any collection of object towards another collection by using a translation schema
import * as _ from 'lodash';
// This curried function return a function that allows to transform any collection of object towards another collection by using a translation schema
// use it like like
// let extractSomething = DataMapper({ wantedProp:'TargerProperty', wantedProp1: 'target.property'});
// let transformedCollection = extractSomething(dataToTransform)
// or
// let transformedData = DataMapper(schema, data);
//
export function DataMapper(schema: any, items?: any): any {
let _schema = _.clone(schema);
@emyann
emyann / AutoFieldMapper.js
Last active August 26, 2016 00:09
This curried function return a function that allows to transform any collection of object towards another collection by using a translation schema
// This curried function return a function that allows to transform any collection of object towards another collection by using a translation schema
// use it like like
// let extractSomething = fieldMapper({ wantedProp:'TargetProperty', wantedProp1: 'target.property'});
// let transformedCollection = extractSomething(dataToTransform)
fieldMapper(schema) {
let _schema = _.clone(schema);
return (items) => {
return _.chain(items)
.map((obj) => {
return _.mapValues(_schema, (path) => {