Skip to content

Instantly share code, notes, and snippets.

View FanaHOVA's full-sized avatar
🛠️
Automating

Alessio Fanelli FanaHOVA

🛠️
Automating
View GitHub Profile
# we use mailcatcher here
config.action_mailer.delivery_method = :smtp
#config.action_mailer.delivery_method = :letter_opener
config.action_mailer.smtp_settings = {
:address => "localhost",
:port => 25,
:domain => "saberespoder.com",
}
/* Libraries */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <time.h>
/*
Realizzate un programma multi processo in C, completo di commento, che svolga quanto segue:
un processo P genera due processi figli P1 e P2.
Il figlio P1 esegue un ciclo indeterminato durante il quale genera casualmente una sequenza
di numeri interi compresi tra 0 e 1023.
Quando il numero generato assume un valore superiore a 512 P1 comunica tale valore a P2.
P2, ricevuto il dato da P1 lo visualizza sullo schermo e lo scrive in un file con diritti di accesso rw- rw- ---.
Durante l’esecuzione, il processo P1 deve gestire il segnale SIGINT in modo tale che se lo riceve stampi sullo schermo
il messaggio: “interruzione disabilitata”.
Il programma termina quando il valore estratto da P1 assume il valore 1000.
s --> simple_s.
s --> simple_s, det, simple_s.
simple_s --> np, vp.
np --> det, sogg.
onp --> det, ogg.
vp --> v, onp.
det --> [il].
det --> [mentre].
iterateExamples([]).
iterateExamples([H1|T1]) :- assert(H1), iterateExamples(T1).
getRightOperator(Albero, L) :- arg(2, Albero, L).
getLeftOperator(Albero, R) :- arg(1, Albero, R).
findSubTree([FirstSub|List], Key, FirstSub) :-
arg(1, FirstSub, Key).
findSubTree([H|T], Key, Result) :- findSubTree(T, Key, Result).
package thikingjava;
import java.util.*;
class Student {
String firstName;
String lastName;
long matricola;
Student(String firstName, String lastName, long matricola) {
this.firstName = firstName;
package javaapplication1;
import java.util.*;
class Author {
String name;
String email;
char gender;
public Author(String name, String email, char gender) {
this.name = name;
@FanaHOVA
FanaHOVA / routes.rb
Created June 15, 2016 17:40
Devise routes and logout
as :user do
get 'login' => 'devise/sessions#new', :as => :new_user_session
post 'login' => 'devise/sessions#create', :as => :user_session
delete 'logout' => 'devise/sessions#destroy', :as => :destroy_user_session
end
<%= link_to('Logout', destroy_user_session_path, :method => :delete) %>
json = ActiveSupport::JSON.decode(File.read('db/cards.json'))
json.each do |card|
Card.create!(game_id: card['id'],
name: card['name'],
cost: card['cost'],
set: card['set'],
card_text: card['text'],
health: card['health'],
attack: card['attack'],
# Binary Search
# O(n logn)
def binarySearch(alist, item):
first = 0
last = len(alist)-1
found = False
while first<=last and not found:
midpoint = (first + last)//2
if alist[midpoint] == item: