Skip to content

Instantly share code, notes, and snippets.

View maesoser's full-sized avatar
:shipit:

Sergio maesoser

:shipit:
View GitHub Profile
@maesoser
maesoser / rom_download.py
Created March 25, 2020 13:51
Tiny script to download ROMs from romsmode.com
#!/usr/bin/env python3
import requests
from bs4 import BeautifulSoup
from time import sleep
from datetime import datetime
import shutil
import argparse
def download_file(name, url):
@maesoser
maesoser / gserver.go
Created March 3, 2020 13:55
Plain and simple http/https test server
package main
import (
"fmt"
"net/http"
"log"
"time"
"flag"
"os"
"strings"
function diario {
DATESTR=$(date +%d%m%Y)
FILENAME="/Users/maesoser/diario/entry_$DATESTR.txt"
if [[ -f "$FILENAME" ]]; then
nano $FILENAME
else
touch $FILENAME
echo -e "------------------------------------------------\n" >> $FILENAME
echo " Entrada $(date '+%A %d-%B, %Y')" >> $FILENAME
echo -e "\n------------------------------------------------\n" >> $FILENAME
#include <Adafruit_NeoPixel.h>
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <ESP8266mDNS.h>
#include <ArduinoJson.h>
@maesoser
maesoser / termo.c
Created February 14, 2020 18:24
CoAP Node that simulates a being a temperature sensor. Written used libcoap library
/* Sergio Maeso Jimenez
* semaesoj@it.uc3m.es
* 03.08.2016
*
* coap code which simulates a temperature sensor
* based on https://github.com/nikosft/libcoap/blob/master/piggybacked/server.c
*
*. gcc -Wall -I /usr/local/include/coap -L /usr/local/lib termo.c -o termo -lcoap-1 -DWITH_POSIX
*/
@maesoser
maesoser / pasarela.go
Created December 13, 2019 08:29
HTTP Proxy client written in go
package main
import (
"bufio"
"fmt"
"io"
"net"
"os"
"strings"
)
@maesoser
maesoser / snmp.py
Last active October 14, 2019 10:31
Wrapper to pysnmp library to easily perform SNMP GET requests.
from pysnmp import hlapi
import argparse
def construct_object_types(list_of_oids):
object_types = []
for oid in list_of_oids:
object_types.append(hlapi.ObjectType(hlapi.ObjectIdentity(oid)))
return object_types
def construct_value_pairs(list_of_pairs):
#!/usr/bin/env bash
function myecho() {
mytime=$( date -u +"%y-%m-%dT%H:%M:%SZ" )
echo "$mytime $1" |tee -a $logpath
}
target="8.8.8.8"
size="1"
interval="1"
@maesoser
maesoser / ping_exporter
Created May 18, 2019 09:12
Simple ping exporter that makes uses of prometheus node_exporter textfile collector
#!/usr/bin/env bash
do_ping () {
local EXPORT_FILE="/tmp/ping_$1.prom"
local OUT=$(ping -nq -c $2 $1)
local ICMP_SENT=$(echo "$OUT" | grep "packets" | awk '{print $1}')
local ICMP_RECV=$(echo "$OUT" | grep "packets" | awk '{print $4}')
local ICMP_MIN=$(echo "$OUT" | grep "avg" | awk '{print $4}' | cut -d/ -f1)
@maesoser
maesoser / pihole_exporter
Created May 18, 2019 09:00
Simple pihole exporter which makes use of prometheus node_exporter textfile collector
#!/usr/bin/env bash
EXPORT_FILE="/tmp/pihole.prom"
OUT=$(curl -s http://127.0.0.1/admin/api.php?summaryRaw | sed -e 's/\"//g')
DNS_DOMAINS_BEING_BLOCKED=$(echo "$OUT" | cut -d, -f1 | cut -d: -f2)
DNS_TOTAL=$(echo "$OUT" | cut -d, -f2 | cut -d: -f2)
DNS_BLOCKED=$(echo "$OUT" | cut -d, -f3 | cut -d: -f2)
DNS_ADS_PCNT=$(echo "$OUT" | cut -d, -f4 | cut -d: -f2)