Skip to content

Instantly share code, notes, and snippets.

View tpsilva's full-sized avatar

Tiago Pasqualini tpsilva

View GitHub Profile
@tpsilva
tpsilva / patch.c
Last active May 3, 2024 15:19
Simple livepatch to make all livepatches to "stay in transition" (well not really, just mocking the transition_show function) forever.
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/livepatch.h>
static ssize_t my_transition_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
return snprintf(buf, PAGE_SIZE-1, "%d\n", 1);
}
@tpsilva
tpsilva / logout_juju.py
Created March 24, 2020 12:39
Simple script that logs your juju controller out of the charmstore
#!/usr/bin/env python
"""
This is a tool for logging your controller out of the charmstore
Usage:
{0} controller-name
"""
import json
import os
import subprocess
@tpsilva
tpsilva / recover_machine_agents.py
Created February 23, 2020 13:54
Recover juju machine agents
#!/usr/bin/env python
"""
This is a tool for recovering lost machine units in current model
Usage:
{0} model-name controller-ip dest-dir
"""
import json
import os
@tpsilva
tpsilva / delete_failed_stacks.sh
Created February 21, 2020 17:57
Delete failed heat stacks
#!/bin/bash
set -e
if ! dpkg -l | grep mysql-client>/dev/null; then
echo "We need to install mysql-client to delete the stacks. Continue? [y/n]"
read answer
[ "${answer,,}" = "y" ] || { echo "Canceled"; exit 0; }
sudo apt install mysql-client -y
printf "\n\n"
fi
@tpsilva
tpsilva / .vimrc
Created August 28, 2014 23:46
.vimrc
set hlsearch
set smartindent
set expandtab
set shiftwidth=4
set softtabstop=4
set nobackup
set encoding=utf-8
set number
set guioptions-=T
set guioptions-=m
@tpsilva
tpsilva / run_algorithms.py
Last active August 29, 2015 14:03
Python script that launches Weka
import os
import subprocess
COMMAND_PREFIX = 'java -cp "C:\Users\Tiago\wekafiles\packages\LibSVM\LibSVM.jar;C:\Users\Tiago\wekafiles\packages\LibSVM\lib\libsvm.jar;C:\Program Files (x86)\Weka-3-7\weka.jar" weka.classifiers.misc.InputMappedClassifier -W '
COMMAND_POSTFIX = " -v -o -M"
ALGORITHMS = [
"weka.classifiers.functions.LibSVM",
"weka.classifiers.bayes.NaiveBayes",
"weka.classifiers.lazy.IBk",