Skip to content

Instantly share code, notes, and snippets.

View supix's full-sized avatar

supix supix

View GitHub Profile
@supix
supix / asyncVersion.cs
Last active August 30, 2018 09:57
Simple console application demonstrating how async programming allows to save time
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp1
{
internal class Program
{
private static void Main(string[] args)
@supix
supix / Bayes.md
Last active June 19, 2018 07:11
Applying Bayes Theorem and verifying if through frequentist probability approach

Context

We are in a university campus. There are two faculties: math and business administration. 10% of student are enrolled in math (then, 90% of students are enrolled in business administration). Within math faculty, 75% students are shy. Within business administration, 15% students are shy.

Problem

I see a student, and he is clearly shy. What's the probability that he is enrolled in math faculty?

Theoretical solution through Bayes Theorem

@supix
supix / Web.Config
Last active June 14, 2018 20:05
Portable way to instantiate a log4net logger throughout all classes
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<appender name="TraceAppender" type="log4net.Appender.TraceAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>
@supix
supix / index.html
Last active May 5, 2018 20:32
Angular template for a website with top nav menu and fixed width
<body>
<div class="topnav">
<a class="active" href="#home">Home</a>
<a href="#news">News</a>
<a href="#contact">Contact</a>
<a href="#about">About</a>
</div>
<div class="content">
<app-root></app-root>
@supix
supix / create_replica_set.bat
Last active December 9, 2017 14:34
These two scripts allow to configure a MongoDB replica set in a msdos console
#mkdir -p /data/rs1 /data/rs2 /data/rs3
"c:\Program Files\mongodb\Server\3.2\bin\mongod" --replSet replica_name --dbpath "c:\data\rs1" --port 27017 --oplogSize 64 --smallfiles
"c:\Program Files\mongodb\Server\3.2\bin\mongod" --replSet replica_name --dbpath "c:\data\rs2" --port 27018 --oplogSize 64 --smallfiles
"c:\Program Files\mongodb\Server\3.2\bin\mongod" --replSet replica_name --dbpath "c:\data\rs3" --port 27019 --oplogSize 64 --smallfiles

Gli smartphone hanno distrutto una generazione?

Un giorno, la scorsa estate, ho chiamato Athena, una ragazza di 13 anni che vive a Houston, in Texas. Mi rispose dal suo iPhone, ne ha uno da quando aveva 11 anni, e sembrava si fosse appena svegliata. Chiacchierammo delle sue canzoni e delle sue trasmissioni preferite e le chiesi cosa le piaceva fare con i suoi amici. "Andiamo al centro commerciale", disse. "Ti ci lasciano i tuo genitori?", le chiesi ricordando i tempi delle mie scuole medie, nel 1980, quando mi divertivo a trascorrere ore di shopping libera dai miei genitori. "No, ci vado con la mia famiglia", rispose. "Andiamo con mia mamma e mio fratello e cammino poco dietro di loro. Devo solo dire a mia mamma dove vado. E mi devo far vedere ogni ora, oppure ogni mezz'ora".

Queste puntate al centro commerciale sono abbastanza rare, circa una al mese. Più spesso Athena e i suoi amici trascorrono il tempo insieme al cellulare, senza il controllo dei genitori. Diversamente dai teenager della mia generazion

@supix
supix / service.ts
Last active June 26, 2017 20:12
Consuming http service in Angular4
//see https://www.sitepoint.com/angular-rxjs-create-api-service-rest-backend/
import { Injectable } from '@angular/core';
import { environment } from 'environments/environment';
import { Http, Response } from '@angular/http';
import { Todo } from './todo';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import 'rxjs/add/observable/throw';