Skip to content

Instantly share code, notes, and snippets.

View toniher's full-sized avatar

Toni Hermoso Pulido toniher

View GitHub Profile
@toniher
toniher / hls.sh
Created March 28, 2016 23:17
Bash script for starting hls with ffmpeg in a raspberry pi
#!/bin/bash
base=/var/hls
mkdir -p $base
cd $base
raspivid -n -w 720 -h 405 -fps 25 -vf -t 86400000 -b 1800000 -ih -o - \
| ffmpeg -y \
@toniher
toniher / hls.service
Last active March 28, 2016 23:22
Simple hls systemd unit
[Unit]
Description=hls: starts hls service
After=nginx.service
[Service]
Type=forking
User=www-data
ExecStart=/usr/local/bin/hls.sh
Restart=on-failure
#!/bin/bash --debugger
set -e
BRANCH="master"
if grep -q BCM2708 /proc/cpuinfo; then
echo "RPI BUILD!"
RPI="1"
fi
[ -n "$1" ] && BRANCH=$1
@toniher
toniher / importWikiEsExtract.py
Last active February 4, 2018 09:36
Simple Python script for extraction es wikipedia extract text
import sys
import requests
import urllib
pagename = str( ' '.join( sys.argv[1:] ) )
wikiurl = "https://es.wikipedia.org/w/api.php?action=query&format=json&titles="+urllib.quote_plus( pagename )+"&prop=extracts&exintro&explaintext&redirects=true"
r = requests.get(wikiurl)
@toniher
toniher / putingroups.pl
Created April 10, 2018 13:56
Simple script for putting in groups in a random way
#!/usr/bin/env perl
use Data::Dumper;
use Text::Trim;
use POSIX;
use List::Util qw(shuffle);
my $file = shift;
my @struct;
my @groups;
@toniher
toniher / mysql-export-csv.pl
Created December 1, 2014 13:28
Export MySQL table/query into CSV
#!/usr/bin/env perl
# Script for exporting MySQL tables into a CSV.
use strict;
use warnings;
use DBI;
use Text::CSV;
use JSON qw( decode_json );
@toniher
toniher / newRecursive.php
Last active May 22, 2018 16:45
Basic recursive iterator for generating a file and directory array
<?php
# Based on https://secure.php.net/manual/en/class.recursivedirectoryiterator.php#111142
# Based on https://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php
$hidden = false;
if ( count( $argv ) > 1 ) {
$ritit = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($argv[1], RecursiveIteratorIterator::SELF_FIRST) );
$r = array();
@toniher
toniher / parseGff.pl
Created February 14, 2019 11:23
Handy parse of GFF files
#!/usr/bin/env perl
# List of IDs - one per line
my $list = shift;
# File with potential IDs, it can be GFF but also othersH
my $gff = shift;
my @ids;
open( LIST, $list ) || die "Cannot open $list";
@toniher
toniher / pergola-webservice.py
Created March 7, 2019 12:04
Webservice script for using pergola through the Web
# -*- coding: utf-8 -*-
"""
Pergola webservice client
~~~~~~~~~~~~~~~~~~~~~~~~~~~
More details at: https://pergola.crg.eu
Usage: python pergola-webservice.py myconfig.json myoutput.zip
"""
import requests
import json
import sys
@toniher
toniher / Dockerfile
Created September 3, 2016 07:39
Example of changing uid and gid of a Docker image - MariaDB
FROM mariadb:10.1
# To be changed here
ENV MYSQL_UID 27
ENV MYSQL_GID 27
RUN usermod -u $MYSQL_UID mysql; groupmod -g $MYSQL_GID mysql;
RUN chown -R mysql:mysql /var/lib/mysql /var/run/mysqld