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
@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) => {
<#
.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()]
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})
@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)){
@emyann
emyann / web.config
Last active August 21, 2017 17:21
ASP.NET web.config configuration for Single Page Application (AngularJS) running on IIS with OwinHttpHandler
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.webServer>
<rewrite>
<rules>
@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() {
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.Owin.Security;
using Microsoft.Owin.Security.OAuth;
using Pollen.Radar.Model;
using Pollen.Radar.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
@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)`
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 } };
}