This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.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()] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<configuration> | |
<system.web> | |
<compilation debug="true" targetFramework="4.5" /> | |
<httpRuntime targetFramework="4.5" /> | |
</system.web> | |
<system.webServer> | |
<rewrite> | |
<rules> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ImmutableClass { | |
constructor() { | |
// return value from class constructor | |
return createInstance() | |
} | |
} | |
let instance = null; | |
function createInstance() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } }; | |
} |
OlderNewer