Skip to content

Instantly share code, notes, and snippets.

View zanza00's full-sized avatar

Simone Picciani zanza00

View GitHub Profile

map e chain rispettivamente in cosa si differenziano?

risposta di @gcanti su italiajs.slack.com in #fp

ambedue servono per risolvere un problema di composizione di funzioni, ma in due situazioni diverse. Partiamo dal caso più semplice, diciamo che hai due funzioni:

f: (a: A) => B
g: (b: B) => C
@zanza00
zanza00 / giulio-functional-message-dump.md
Last active March 18, 2019 11:15
Dump di quando detto da @gcanti nel canale #fp di italiajs in data 1 marzo 2019

Questa non è farina del mio sacco, io ho solo copia incollato la discussione. Kudos to Giulio Canti

@vncz ho un consiglio su come procedere a strutturare un programma funzionale, con me ha funzionato bene, vediamo se funziona anche per te

In linea teorica e generale procedo così

  • dominio
  • firma del programma
  • firme delle operazioni di base
@zanza00
zanza00 / wallpapers.10m.js
Last active July 7, 2018 23:57
bitbar plugin, work in progress
#!/usr/bin/env /usr/local/bin/node
const { execSync } = require('child_process');
const basedir =
'/Users/simonepicciani/Dropbox (Personal)/IFTTT/reddit/wallpapers/';
const command =
"sqlite3 '/Users/simonepicciani/Library/Application Support/Dock/desktoppicture.db' 'select value from data;'";
const res = execSync(command)
.toString('utf8')
@zanza00
zanza00 / webpack.base.babel.js
Last active June 22, 2017 13:50
inline svg trough webpack
}, {
// if the file ends with .inline.svg read the content from file
// useful if you want to inline the image and style it via css
test: /\.inline.svg$/,
loader: 'raw-loader',
}, {
// if the file ends only with .svg load as an image
// to use it like this <img scr={...} />
test: /(s)((?!inline).)*svg$/,
loader: 'file-loader',
@zanza00
zanza00 / VerbalArithmetic.scala
Last active December 23, 2016 15:58
A more general approach to resolve verbal arithmetic using scala API, completely based on the talk by Filippo Vitale => https://youtu.be/sot44l8zKuo
/**
* Created by simone.picciani on 21/12/2016.
*/
object ScalaAPI {
def main(args: Array[String]): Unit = {
val initTime = System.currentTimeMillis
// val phrase = "send more money"
@zanza00
zanza00 / HighChart-PieToSeries.js
Created May 18, 2016 15:43
how to convert the data from a Pie Chart to a Histogram in Highcharts
//Uses Highcharts and Rambda
// live example for conversion => http://goo.gl/I2OdwZ
// jsbin of result
var pieData = [
{ y: 1.242, name: 'EM' }, { y: 29.017, name: 'EM' }, { y: 2.874, name: 'EM' }, { y: 0.474, name: 'EM' }, { y: 33.363, name: 'EM' }, { y: 33.03, name: 'EM' },
{ y: 2.67, name: 'NA' }, { y: 28.551, name: 'NA' }, { y: 2.195, name: 'NA' }, { y: 0.524, name: 'NA' }, { y: 34.131, name: 'NA' }, { y: 31.929, name: 'NA' },
{ y: 0.138, name: 'FE' }, { y: 28.115, name: 'FE' }, { y: 1.576, name: 'FE' }, { y: 0.829, name: 'FE' }, { y: 34.923, name: 'FE' }, { y: 34.419, name: 'FE' },
{ y: 0.547, name: 'GC' }, { y: 25.642, name: 'GC' }, { y: 2.503, name: 'GC' }, { y: 0.398, name: 'GC' }, { y: 35.753, name: 'GC' }, { y: 35.157, name: 'GC' }
];
@zanza00
zanza00 / GenerateReproducibleID.js
Last active April 5, 2016 22:20
when it's passed an object take every value, strip spaces and return a string
//uses Ramdajs
function f( object ) {
function opt( val ) {
return String(val) || 'None';
}
return R.replace( /\s+|\.+|\,+/g, '' , R.join('', R.map( opt, R.values( object ) ) ) )
}
var o = {a:"This prop has spaces",n:12.3, r:null, z:0, data:[1,2,3]}
@zanza00
zanza00 / checkFunction.js
Created March 24, 2016 14:30
Function that checks if something is a function, YO DAWG
/**
* isFunction - Function that check if a something is a function, yo dawg
*
* @param {...*} functionToCheck function to check without the parens ()
* @return {boolean}
*/
function isFunction( functionToCheck ) {
var getType = {};
return functionToCheck && getType.toString.call( functionToCheck ) === '[object Function]';
}