Skip to content

Instantly share code, notes, and snippets.

View jmunozal's full-sized avatar

Jesús Muñoz Alloza jmunozal

View GitHub Profile
@jmunozal
jmunozal / getk8sclient.go
Created December 30, 2021 11:15
get Kubernetes client
import (
"context"
"encoding/json"
mux "github.com/gorilla/mux"
"github.com/spotahome/kooper/v2/log"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/util/homedir"
@jmunozal
jmunozal / split.cpp
Created November 13, 2017 15:09
c++ split string
std::string s = "scott>=tiger>=mushroom";
std::string delimiter = ">=";
size_t pos = 0;
std::string token;
while ((pos = s.find(delimiter)) != std::string::npos) {
token = s.substr(0, pos);
std::cout << token << std::endl;
s.erase(0, pos + delimiter.length());
}
@jmunozal
jmunozal / convert.c
Created October 31, 2017 13:32
How to convert NTP time to Unix Epoch time in C language (Linux)
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <stdint.h>
#include <getopt.h>
#define OFFSET 2208988800ULL
void ntp2tv(uint8_t ntp[8], struct timeval *tv)
{
@jmunozal
jmunozal / Samples.r
Created October 16, 2017 13:52
CLT sampling 5 values from normal distribution and histogram (R)
s <- NULL
for (i in 1:5000) {
# 5 values normal distribution mean 40 sd 6
t<-sum(rnorm(5, 40, 6))
s[i] <- t
}
hist(s)
@jmunozal
jmunozal / Seccion2.R
Created October 16, 2017 13:35
Central Limit Theorem
setwd("/Users/kepler/Dropbox/Classroom/UOC - Master Bioinformatica/Software para el Análisis de Datos/PACS/PAC2")
#A. Generación de valores aleatorios
valores <- runif(100000, min = 1, max = 5)
#B. Agrupación en 20 columnas
matriz <- matrix(valores, ncol = 20)
# histogramas