Skip to content

Instantly share code, notes, and snippets.

View diegopso's full-sized avatar
💭
👾

Diego Oliveira diegopso

💭
👾
  • University of Bern
  • Bern, Switzerland
View GitHub Profile
@diegopso
diegopso / SessionManager.cc
Last active July 1, 2022 16:57
Static variable in module sample Omnet++
#include "SessionManager.h"
using namespace sdicn;
Define_Module(sdicn::SessionManager);
int SessionManager::binderCounter = 0;
vector<SessionManager::SessionBinding> SessionManager::bindings = vector<SessionBinding>();
void SessionManager::initialize()
{
@diegopso
diegopso / TopologyContainer.cc
Created July 1, 2022 16:04
Static Variable Omnet++
#include "TopologyContainer.h"
using namespace sdicn;
cTopology TopologyContainer::instance;
bool TopologyContainer::isInitialized = false;
void TopologyContainer::initialize() {
TopologyContainer::instance.extractByProperty("networkNode");
TopologyContainer::isInitialized = true;
@diegopso
diegopso / cpu_monitor.sh
Created July 6, 2018 14:18
Monitor Hardware Usage Ubuntu
#!/bin/bash
echo 'cpu,mem,args' >> ps.csv
while true; do
(ps -e -o pcpu,pmem,args --sort=-pmem,-pcpu --no-headers | sed 's/^[ \t]*//;s/[ \t]*$//' | sed -e 's/\s\+/,/' | sed -e 's/\s\+/,/' | sed -r -e 's/^([0-9\.]+),([0-9\.]+),([^ ]+)(.*)?/\1,\2,\3/g' | sed -r -e 's/^([0-9\.]+),([0-9\.]+),(.*\/)(.*)/\1,\2,\4/g') >> ps.csv;
sleep 10;
done
@diegopso
diegopso / gerencia.py
Last active November 18, 2016 16:04
Trabalho de Gerencia de Redes 2016-2
# // Sample Command to Run Simulation
# //
# // ./waf --pyrun "scratch/gerencia.py --trafic=2 --nWifi=5 --verbose=False --seed=3"
# //
# // nWifi - Number of wifi STA devices
# // verbose - Tell echo applications to log if true
# // trafic - Tipo de trafico da simulacao: 1 - CBR, 2 - Rajada
# // duration - The duration of the simullation in seconds
# // seed - The seed to generate random values
# //
@diegopso
diegopso / main.py
Created May 18, 2016 20:14
First code with pyopencl
import numpy
import pyopencl as cl
import os
#os.environ['PYOPENCL_COMPILER_OUTPUT'] = '1'
os.environ['PYOPENCL_CTX'] = '0:1'
N = 5
# create host arrays
@diegopso
diegopso / host.cpp
Last active May 18, 2016 19:02
Matrix Mull Cpp Opencl
#include <iostream>
#include <CL/cl.hpp>
int init(float* A, int n) {
int i,j;
for(i=0;i<n;i++){
for(j=0;j<n;j++){
A[i*n+j] = 1;
}
}
@diegopso
diegopso / kernel4-mat_mul_naivev.c
Last active April 13, 2016 22:08
Laboratório 6 Tópico em Linguagem de Programação - UNICAMP 2016-1
/***************************************************************************
* Copyright (C) 2014 by Edson Borin and Raul Baldin *
* edson@ic.unicamp.br *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
<?php
/**
* PHP item based filtering
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
@diegopso
diegopso / interceptors.js
Created January 18, 2016 02:56
Angular Authorization with Intetceptors and ngStorage
$httpProvider.interceptors.push(['$q', '$location', '$localStorage', function($q, $location, $localStorage) {
return {
'request': function (config) {
config.headers = config.headers || {};
if ($localStorage.token) {
config.headers.Authorization = 'Portador ' + $localStorage.token;
}
return config;
},
'responseError': function(response) {
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" integrity="sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==" crossorigin="anonymous"> <!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>
<style type="text/css">
.exemplo {
width: 200px;