Skip to content

Instantly share code, notes, and snippets.

View toniher's full-sized avatar

Toni Hermoso Pulido toniher

View GitHub Profile
@toniher
toniher / lpsolve_ratings.py
Last active August 29, 2015 13:56
Python script for importing old ratings MediaWiki extension into a dump for VoteNY using LP_solve
# Python script for importing old ratings MediaWiki extension http://www.mediawiki.org/wiki/Extension:AjaxRatingScript
# into a dump for more suitable new extension http://www.mediawiki.org/wiki/Extension:VoteNY
# Using LP_solve Python wrapper
from lpsolve55 import *
import MySQLdb
def main():
host = "localhost"
@toniher
toniher / keep_filextension_mwupload.js
Last active August 29, 2015 13:56
Bit of jQuery code for keeping suitable filename extension in MediaWiki file upload form. Useful when used with default filename parameter in Semantic Forms http://www.mediawiki.org/wiki/Extension:Semantic_Forms/Defining_forms
/** Make filename readonly, so filename is either the default one defined in the form or the filename in your drive **/
$("#mw-upload-form #wpDestFile").attr('readonly', true);
/** Keep file extension in upload. Default filename is changed according the filename extension uploaded **/
$("input:file").change(function (){
var filename = $('input[type=file]').val().replace(/C:\\fakepath\\/i, '');
var extension = filename.substr( (filename.lastIndexOf('.') +1) );
var subs = "."+extension;
var filenamef = $("#wpDestFile").val();
var extensionf = filenamef.substr( (filenamef.lastIndexOf('.') +1) );
@toniher
toniher / catculture2014-wikipedia.pl
Last active August 29, 2015 13:57
Catalan culture challenge Wikipedia 2014 http://en.wikipedia.org/wiki/Wikipedia:Catalan_culture_challenge/list script for checking page length in English Wikipedia and coverage in other Wikimedia sister projects.
#!/usr/bin/env perl -w
use MediaWiki::Bot;
use LWP::Simple qw(get);
use JSON qw(from_json);
use URI::Escape;
use Data::Dumper;
use utf8;
binmode STDOUT, ":utf8";
@toniher
toniher / psiblast.xsl
Last active August 29, 2015 14:02
XSL transformation 1.0 stylesheet for NCBI PSIBLAST XML
<?xml version='1.0' encoding="ISO-8859-1" ?>
<!--
XSLT 1.0 Stylesheet for converting NCBI PSIBLAST XML into JSON with different string params as input
Usage: xsltproc psiblast.xsl output.xml > output.json
Toni Hermoso Pulido @toniher, 2014 - GPLv 3 or later
Reference http://plindenbaum.blogspot.com.es/2008/05/ncbi-blast-xslt-xhtml-svg.html
-->
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0' >
<xsl:output method="text" />
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 3 in line 1.
Rcode Name RGB HTML
1 white 255,255,255 #FFFFFF
2 aliceblue 240,248,255 #F0F8FF
3 antiquewhite 250,235,215 #FAEBD7
4 antiquewhite1 255,239,219 #FFEFDB
5 antiquewhite2 238,223,204 #EEDFCC
6 antiquewhite3 205,192,176 #CDC0B0
7 antiquewhite4 139,131,120 #8B8378
8 aquamarine 127,255,212 #7FFFD4
9 aquamarine1 127,255,212 #7FFFD4
Verifying that +toniher is my Bitcoin username. You can send me #bitcoin here: https://onename.io/toniher
@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 );
#!/bin/bash
### BEGIN INIT INFO
# Provides: YOUR_NAME_HERE
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop the forever nodejs application. Requires chpst
### END INIT INFO
#!/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 / rtmp-nginx.sh
Created January 11, 2015 20:33
rtmp-nginx.sh configuration file
#!/bin/bash
mkdir -p /tmp/hls
on_die () {
# kill all children
pkill -KILL -P $$
}
trap 'on_die' TERM