Skip to content

Instantly share code, notes, and snippets.

View tembleking's full-sized avatar
🏠
Working from home

Fede Barcelona tembleking

🏠
Working from home
View GitHub Profile
@tembleking
tembleking / Aula.java
Created March 11, 2014 11:54
Examen Java 1hCFGS [28/02/2014]
public class Aula {
private Equipo[] equipos;
private String nombreAula;
public Aula(String nombreAula, Equipo[] equipos)
{
this.nombreAula = nombreAula;
this.equipos = new Equipo[20];
try
{
@tembleking
tembleking / ExamenFuncionesC.c
Created March 11, 2014 11:57
Examen de funciones en C [28/01/2014]
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//! @author Federico Barcelona
//! @date 28/01/2014
//!////////////////////////// BLOQUE 1 ////////////////////////////////////
//! Ejercicio 1 ///////////////////////////////////////////////////////////////
int multiplos(int num1, int num2)
{
if (num1 % num2 == 0)
@tembleking
tembleking / chan.hpp
Created August 18, 2018 16:15
Simple C++ implementation of Golang channels
/*
The MIT License (MIT)
Copyright (c) 2018 Federico Barcelona <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, subject to the following conditions:
@tembleking
tembleking / app.js
Created September 28, 2018 06:11
Prometheus
const client = require('prom-client');
const express = require('express');
const server = express();
const register = new client.Registry();
// Probe every 5th second.
const intervalCollector = client.collectDefaultMetrics({prefix: 'node_', timeout: 5000, register});
const counter = new client.Counter({
name: "node_my_counter",
@tembleking
tembleking / app.js
Created October 4, 2018 21:04
Prometheus Node.js Example
const client = require('prom-client');
const express = require('express');
const server = express();
const register = new client.Registry();
// Probe every 5th second.
const intervalCollector = client.collectDefaultMetrics({prefix: 'node_', timeout: 5000, register});
const counter = new client.Counter({
name: "node_my_counter",
@tembleking
tembleking / main.go
Created October 4, 2018 21:06
Prometheus Golang Example
package main
import (
"fmt"
"log"
"math/rand"
"net/http"
"time"
"github.com/prometheus/client_golang/prometheus"
@tembleking
tembleking / main.java
Created October 4, 2018 21:06
Prometheus Java Example
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
import io.prometheus.client.*;
import io.prometheus.client.exporter.HTTPServer;
import io.prometheus.client.hotspot.DefaultExports;
import java.io.IOException;
import java.net.InetSocketAddress;
@tembleking
tembleking / main.py
Created October 4, 2018 21:07
Prometheus Python Example
import prometheus_client as prom
import random
import time
from threading import Thread
from flask import Flask, request
from flask_prometheus import monitor
req_summary = prom.Summary('python_my_req_example', 'Time spent processing a request')
@tembleking
tembleking / main.go
Created October 5, 2018 22:42
Golang Expvar Example
package main
import (
"expvar"
"net/http"
"time"
"os"
"io/ioutil"
"strings"
"strconv"
@tembleking
tembleking / gist:71c6d33a3058f5ade89fc31710d7d46c
Created October 5, 2018 22:43
Golang Expvar Response Example
$ curl localhost:8080/debug/vars
{
"cmdline": [
"/go-expvar"
],
"memstats": {
"Alloc": 878208,
"TotalAlloc": 878208,
"Sys": 3084288,
"Lookups": 277,