Skip to content

Instantly share code, notes, and snippets.

View ABeltramo's full-sized avatar

ABeltramo

View GitHub Profile
@ABeltramo
ABeltramo / main.cpp
Last active March 4, 2016 15:39
Nimbus3000
//
// main.cpp
// Nimbus3000
//
// Created by Ale on 04/03/16.
// Copyright © 2016 ABeltramo. All rights reserved.
//
#include <iostream>
#include <fstream>
@ABeltramo
ABeltramo / main.cpp
Created March 13, 2016 12:05
Torero Escamillo
struct indumento{
bool indossabile;
vector<int> lista;
indumento():indossabile(true){}
};
int N,M,Q,non_indossabili;
indumento indumenti[100000];
void propaga(int n){
@ABeltramo
ABeltramo / main.cpp
Last active March 13, 2016 12:17
Pirata Barbablù
#define INFINITO 1000000
struct corridoio{
int porta_a, lunghezza;
corridoio(int p, int l):porta_a(p), lunghezza(l){} //inizializzo le variabili
}
struct cabina{
bool aria;
list <corridoio> corridoi;
int distanza;
@ABeltramo
ABeltramo / Generatore.sh
Last active April 7, 2016 16:51
Correttore olimpiadi
#!/bin/bash
randomResult=0
random ()
{ # Genera un numero random tra due intervalli
lower=$1
upper=$2
randomResult=-99 #initialize
while [ "$randomResult" -le $lower ]
do
randomResult=$RANDOM
@ABeltramo
ABeltramo / cloudflare.sh
Created December 15, 2016 13:12
Cloudflare iptables
#!/bin/bash
# Only once setup:
# iptables -N cloudflare
# iptables -t filter -I INPUT -j cloudflare -p tcp -m multiport --dports http,https
iptables -F cloudflare
for i in `curl https://www.cloudflare.com/ips-v4`; do
iptables -A cloudflare -p tcp -s $i -m multiport --dports domain,http,https -j ACCEPT;
done
iptables -A cloudflare -j RETURN
@ABeltramo
ABeltramo / Test.java
Created January 12, 2017 12:44
Twitter4J Friends
private ArrayList<Long> getAllFriendsIDs(String user) throws TwitterException{
ArrayList<Long> tmp = new ArrayList<>();
ArrayList<Long> friends = new ArrayList<>();
Long cursor = -1L;
IDs ids = null;
checkAPICall("/users/show/:id");
User curUser = _tw.showUser(user);
// Take the min number of user
if(curUser.getFollowersCount() < curUser.getFriendsCount()){
https://www.youtube.com/watch?v=OGr1_qIstlE
https://www.youtube.com/watch?v=U-iAMaqibXU
https://www.youtube.com/watch?v=_qA4p_XWUCA
https://www.youtube.com/watch?v=XI1VpElKWF8
https://www.youtube.com/watch?v=G4UspBs3DGQ
https://www.youtube.com/watch?v=6miaTf1gF4g
https://www.youtube.com/watch?v=AoZhXA10EEI
https://www.youtube.com/watch?v=1m4tYUfYCj4
https://www.youtube.com/watch?v=dv5_QW17xJQ
https://www.youtube.com/watch?v=9aHQnDTd1y4
@ABeltramo
ABeltramo / test.R
Created December 5, 2017 12:01
Pseudocodice R per il framework
INIT <- function(numeroDiNodi){ # INIT() riceve in input il numero di nodi iniziali del framework
Grafo <- inizializzaGrafo() # Crea il grafo globale iniziale
Matrice <- convertiGrafoInMatrice(Grafo) # Converte il grafo prima generato in una matrice
ListaFinale <- vector(mode="list") # Variabile temporanea: lista di tuple
for (i in 1:numeroDiNodi){ # Per ogni suddivisione della matrice creata
SottoMatrice <- dividiMatrice(Matrice, i , numeroDiNodi) # dividiMatrice spezza la matrice per righe
ListaFinale[i] <- list(input = SottoMatrice, # Creo la tupla [input = SottoMatrice
popolazione = randomPopulation()) # popolazione = popolazione randomica
}
return ListaFinale #
\begin{algorithm}
\caption{ConcurrentGain - Le chiamate al calcolo dell'information gain vengono eseguite in parallelo utilizzando tutti i core disponibili.}
\label{alg:ID3_concurrentGain}
\begin{algorithmic}[1]
\Procedure{maxInformationGain}{$Dataset, Attributes, TargetAttributes$}
\Statex Calcola parallelamente l'attributo che meglio suddivide il dataset in input per classificare il target.
\State $Threads \gets $ [ ] \Comment{Creo un array di riferimenti ai Thread}
\ForAll{$Attribute$ in $Attributes$}
\If{$Attribute \not= TargetAttributes$} \Comment{Salto l'attributo Target}
\State $Threads[i] \gets concurrentGain(Attribute)$
@ABeltramo
ABeltramo / weather.30m.py
Last active September 2, 2019 10:54
BitBar Weather with icons
#!/usr/bin/python
# -*- coding: utf-8 -*-
# <bitbar.title>Weather</bitbar.title>
# <bitbar.version>v3.5.0</bitbar.version>
# <bitbar.author>Daniel Seripap</bitbar.author>
# <bitbar.author.github>seripap</bitbar.author.github>
# <bitbar.desc>Detailed weather plugin powered by DarkSky with auto location lookup. Supports metric and imperial units. Needs API key from https://darksky.net/dev/.</bitbar.desc>
# <bitbar.image>https://cloud.githubusercontent.com/assets/683200/16276583/ff267f36-387c-11e6-9fd0-fc57b459e967.png</bitbar.image>
# <bitbar.dependencies>python</bitbar.dependencies>