Skip to content

Instantly share code, notes, and snippets.

View yostane's full-sized avatar

Yassine Benabbas yostane

View GitHub Profile
@yostane
yostane / maternite.py
Created September 10, 2018 20:07
Exercice 2.4 sur les files d'attente
# coding=utf-8
import math
import decimal
def B(s, a):
denom = 0
for i in range(0, s+1):
duration wage-increase-first-year wage-increase-second-year wage-increase-third-year cost-of-living-adjustment working-hours pension standby-pay shift-differential education-allowance statutory-holidays vacation longterm-disability-assistance contribution-to-dental-plan bereavement-assistance contribution-to-health-plan class
1 5 ? ? ? 40 ? ? 2 ? 11 average ? ? yes ? good
2 4.5 5.8 ? ? 35 ret_allw ? ? yes 11 below_average ? full ? full good
? ? ? ? ? 38 empl_contr ? 5 ? 11 generous yes half yes half good
3 3.7 4 5 tc ? ? ? ? yes ? ? ? ? yes ? good
3 4.5 4.5 5 ? 40 ? ? ? ? 12 average ? half yes half good
2 2 2.5 ? ? 35 ? ? 6 yes 12 average ? ? ? ? good
3 4 5 5 tc ? empl_contr ? ? ? 12 generous yes none yes half good
3 6.9 4.8 2.3 ? 40 ? ? 3 ? 12 below_average ? ? ? ? good
2 3 7 ? ? 38 ? 12 25 yes 11 below_average yes half yes ? good
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 36 columns, instead of 18 in line 3.
date,plant-stand,precip,temp,hail,crop-hist,area-damaged,severity,seed-tmt,germination,plant-growth,leaves,leafspots-halo,leafspots-marg,leafspot-size,leaf-shread,leaf-malf,leaf-mild,stem,lodging,stem-cankers,canker-lesion,fruiting-bodies,external-decay,mycelium,int-discolor,sclerotia,fruit-pods,fruit-spots,seed,mold-growth,seed-discolor,seed-size,shriveling,roots,class
october,normal,gt-norm,norm,yes,same-lst-yr,low-areas,pot-severe,none,90-100,abnorm,abnorm,absent,dna,dna,absent,absent,absent,abnorm,no,above-sec-nde,brown,present,firm-and-dry,absent,none,absent,norm,dna,norm,absent,absent,norm,absent,norm,diaporthe-stem-canker
august,normal,gt-norm,norm,yes,same-lst-two-yrs,scattered,severe,fungicide,80-89,abnorm,abnorm,absent,dna,dna,absent,absent,absent,abnorm,yes,above-sec-nde,brown,present,firm-and-dry,absent,none,absent,norm,dna,norm,absent,absent,norm,absent,norm,diaporthe-stem-canker
july,normal,gt-norm,norm,yes,same-lst-yr,scattered,severe,fungicide,lt-80,abnorm,abnorm,absent,dna,dna,absent,absent,a
@yostane
yostane / variables.swift
Created November 8, 2017 13:38
swift variables
//Declaring variables in swift
var year = 2017
//swift infers the type of the variables
var text = "Hello"
//the compiler then sets the type of "text" to "string"
//this code will fail during compilation
//text = 2
//printing variables
print(year);
//The "duration" variable contains Execution time when we delete entities using for loop
using (var context = new VideoGamesDatabaseContext())
{
start = DateTime.Now;
//delete all previous entitiies
foreach (var videoGame in context.VideoGames.Where(predicate))
{
context.Remove(videoGame);
}
context.SaveChanges();
using (var context = new VideoGamesDatabaseContext())
{
var res = context.VideoGames.Where(vg => predicate(vg)).Delete(x => x.BatchSize = 500);
}
using (var context = new VideoGamesDatabaseContext())
{
foreach (var videoGame in context.VideoGames.Where(predicate))
{
context.Remove(videoGame);
}
context.SaveChanges();
}
using Microsoft.AspNetCore.Mvc.RazorPages;
using System;
namespace RazorPages
{
/// <summary>
/// This class is the code behind of the Contacts.cshtml page
/// </summary>
public class Contacts: PageModel
{
@page
@using RazorPages
<!-- the code is in the Contacts class. This class will be placed in a separate file -->
@model Contacts
<!-- create a h2 tag with static content -->
<h2>Contacts</h2>
<!-- print the Message and Name properties from the Contacts class -->>
<p>
@page
@model IndexModel
@using Microsoft.AspNetCore.Mvc.RazorPages
<!-- code part -->
@functions {
public class IndexModel : PageModel
{
public string Message { get; private set; } = "In page model: ";