Skip to content

Instantly share code, notes, and snippets.

View Canx's full-sized avatar

Ruben Cancho Canx

View GitHub Profile
@Canx
Canx / mezclar.c
Created March 1, 2019 16:18
mezclar.c
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
int comparar(char *cad1, char *cad2) {
int i=0;
while ((cad1[i]!='\0') && (cad2[i] != '\0')) {
if (cad1[i] < cad2[i]) return -1;
if (cad1[i] > cad2[i]) return 1;
#!/bin/bash
# Grabar archivo a la vez que hacemos multicast y grabar audio también!!!
filename="salida"
URL="udp://239.0.0.1:1234/"
rm -rf "{$filename}.mp4"
titulo=$(zenity --entry --title="Grabación" --text="Introduce el titulo del video (se empezará a grabar a continuación:")
now=$(date +"%m_%d_%Y")
ffmpeg -f x11grab -s 1920x1080 -framerate 10 -i :0.0 -f pulse -i default -acodec libmp3lame -tune zerolatency -c:v libx264 -x264-params keyint=5:min_keyint=2 -pix_fmt yuv420p -s 1280x800 -threads 0 -f tee -map 0:v -map 1:a "${filename}.mp4|[f=mpegts]${URL}"
# Aquí tenemos que recortar los últimos 5 segundos y añadir la cabecera y el final.
@Canx
Canx / gist:16245df14c286370ec7958f7be6f6fc4
Last active October 14, 2018 20:16
ffmpeg screencast streaming
# Servidor multicast
ffmpeg -f x11grab -s 1920x1080 -framerate 10 -i :0.0 -c:v libx264 -tune zerolatency -x264-params keyint=5:min_keyint=2 -pix_fmt yuv420p -s 1280x800 -threads 0 -f mpegts udp://239.0.0.1:1234
# Cliente multicast
ffplay -probesize 32 -sync ext udp:239.0.0.1:1234
# Grabar archivo a la vez que hacemos multicast y grabar audio también!!!
now=$(date +"%m_%d_%Y")
ffmpeg -f x11grab -s 1920x1080 -framerate 10 -i :0.0 -f pulse -i default -acodec libmp3lame -tune zerolatency -c:v libx264 -x264-params keyint=5:min_keyint=2 -pix_fmt yuv420p -s 1280x800 -threads 0 -f tee -map 0:v -map 1:a "salida_${now}.mp4|[f=mpegts]udp://239.0.0.1:1234/"
@Canx
Canx / menu.sh
Created September 4, 2018 20:07
#!/bin/bash
HEIGHT=15
WIDTH=40
CHOICE_HEIGHT=4
BACKTITLE="Control de Internet, por Ruben Cancho."
TITLE="Menu principal"
MENU="Elige una opción:"
OPTIONS=(1 "Quitar Internet a todos"
#!/bin/bash
exec 3>&1;
urls=$(dialog --title "URL accesibles" --inputbox "Indica las URL's que podrán ser accesibles (separadas por espacio)" 0 60 2>&1 1>&3);
exitcode=$?;
exec 3>&1;
for url in $urls; do
echo "iptables -I FORWARD -s $url -j ACCEPT";
done
#!/bin/bash
exec 3>&1;
ips=$(dialog --title "IPs internas permitidas" --inputbox "Indica las IPs que podrán navegar sin restricciones (192.168.0.X)" 0 0 2>&1 1>&3);
exec 3>&1;
for ip in $ips; do
echo "iptables -I FORWARD -s 192.168.0.$ip -j ACCEPT";
done
#!/bin/bash
exec 3>&1;
ips=$(dialog --title "IPs internas permitidas" --inputbox "Indica las IPs que podrán navegar sin restricciones (192.168.0.X)" 0 0 2>&1 1>&3);
exec 3>&1;
for ip in $ips; do
echo "iptables -I FORWARD -s 192.168.0.$ip -j ACCEPT";
done
@Canx
Canx / reset_courses.sh
Created August 22, 2018 14:41
Script to reset courses and unenrol students.
#!/bin/bash
#
# 'reset_courses' is a script to bulk reset all courses and unenrol their students.
# by Ruben Cancho (@canx)
#
# DEPENDENCIES: moosh installed.
# NOTE: for deleting old students is recommended to install "Inactive User Cleanup" plugin
#
############ CONFIG #############
userdb='root' # add your moodle db user
options {
directory "/var/cache/bind";
zone-statistics yes;
statistics-file "/var/log/bind/named.stats";
// TODO: Actualizar bind para que esté soportado!
//statistics-channels {
// inet 127.0.0.1 port 8888 allow { 127.0.0.1; };
// inet ::1 port 8888 allow { ::1; };
logging {
channel default_log {
file "/var/log/bind/default" versions 3 size 20m;
print-time yes;
print-category yes;
print-severity yes;
severity info;
};
channel auth_servers_log {
file "/var/log/bind/auth_servers" versions 100 size 20m;