Skip to content

Instantly share code, notes, and snippets.

module Mycont_01 where
import Control.Monad.Cont
fattoriale :: Int -> Int
Cont (\c -> c (fattoriale 0)) = return 1
Cont (\c -> c (fattoriale n)) = Cont (\c -> c (fattoriale (n - 1)))
>>= (\x -> Cont (\c -> c (n*x)))
@Muzietto
Muzietto / WEBSTORM_EXPRESS_INSTALL_REPORT.txt
Created September 12, 2015 06:30
A bunch of ECONNRESET from npmjs.org
Error creating Node.js Express App. Failed command:
"C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" install
Exit code: -1
Standard error:
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info preinstall [email protected]
npm info attempt registry request try #1 at 08:22:57
npm http request GET https://registry.npmjs.org/cookie-parser
@Muzietto
Muzietto / build.xml
Last active September 29, 2015 12:36
google/i18n/libphonenumber - ant project to compile single-country JS executables using the Closure compiler
<?xml version="1.0" ?>
<!--
SCLEXE - single-country libphonenumber executable
Author: Marco Faustinelli ([email protected])
Web: http://faustinelli.net/
http://faustinelli.wordpress.com/
Version: 1.0
The MIT License - Copyright (c) 2015 SCLEXE Project
-->
<project basedir="." name="libphonenumber-javascript" default="all">
@Muzietto
Muzietto / slice_country.js
Created September 29, 2015 12:35
google/i18n/libphonenumber - node.js script to prepare single-country metadata files
/*
SCLEXE - single-country libphonenumber executable
Author: Marco Faustinelli ([email protected])
Web: http://faustinelli.net/
http://faustinelli.wordpress.com/
Version: 1.0
The MIT License - Copyright (c) 2015 SCLEXE Project
*/
var fs = require('fs');
@Muzietto
Muzietto / writer_monad_validation.html
Created October 11, 2015 17:41
Validating a form with a writer monad
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>monadic validation</title>
<style>
body { font-family: Verdana; font-size: 1.5em; }
.horizon { width: 500px; margin: 0 auto; padding: 10px; border: 2px solid red; }
.horizon input, .horizon label { margin: 10px; }
@Muzietto
Muzietto / load_csv_in_browser_memory.html
Last active October 11, 2015 19:20
HTML5 FileReader to load CSV file in page and use it as JS variable
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>FileWriter API</title>
<style>
body { font-family: Verdana; font-size: 1.5em; }
.horizon { width: 500px; margin: 0 auto; padding: 10px; border: 2px solid red; }
.horizon input, .horizon label { margin: 10px; }
@Muzietto
Muzietto / pom.xml with annotations
Last active November 30, 2016 11:15
pom.xml with annotations
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.xxx.yyy</groupId>
<artifactId>XXXX</artifactId>
<version>1.2.0-SNAPSHOT</version>
</parent>
<groupId>xxx.yyy.migration</groupId>
<artifactId>YYY</artifactId>
@Muzietto
Muzietto / ClassNotFoundCrappyEclipse.bug
Created December 1, 2016 11:05
When tests do not start on Eclipse due to ClassNotFoundException
- right-click project with issue
- maven --> update project
- de-select "clean projects" at the bottom
- OK
@Muzietto
Muzietto / StandaloneServer.java
Created December 15, 2016 13:38
Launching a standalone Jetty to run whatever...
package com.wcg.product.ajax.ajaxserver.connectors;
import java.net.URL;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.xml.XmlConfiguration;
public class StandaloneServer {
@Muzietto
Muzietto / MinMaxDivision.js
Created December 31, 2016 08:37
Human-readable solution for the MinMaxDivision puzzle at Codility (https://codility.com/programmers/lessons/14-binary_search_algorithm/min_max_division/)
function solution(K, M, A) {
// M is a red herring
return minimalLargeSumBinarySearch(K, A);
}
function minimalLargeSumBinarySearch(maxNumBlocks, arra) {
var lowerBoundLargeSum = Math.max.apply(null, arra);
var upperBoundLargeSum = arra.reduce((a,c)=>a+c,0);
var result = -1;