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 / 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 / RandomDateTimeGenerator.ps1
Created June 15, 2016 04:27
A Powershell random generator for dates and times
function Get-RandomDateBetween{
<#
.EXAMPLE
Get-RandomDateBetween -StartDate (Get-Date) -EndDate (Get-Date).AddDays(15)
#>
[Cmdletbinding()]
param(
[parameter(Mandatory=$True)][DateTime]$StartDate,
[parameter(Mandatory=$True)][DateTime]$EndDate
)
@emyann
emyann / AngularTruncateText.js
Created June 16, 2016 20:32
AngularJs filter to truncate text
angular
.module('ng')
.filter('truncate', function () {
/**
* @param {boolean} wordwise - if true, cut only by words bounds
* @param {string} max - max length of the text, cut to this number of chars
* @param {string} tail - add this string to the input string if the string was cut
*/
return function (value, wordwise, max, tail) {
if (!value) return '';
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 / 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) => {
@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);
<#
.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 / 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"}