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
#!/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
@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
@toniher
toniher / neo4jclient-ncbi-py2neo-1.6.py
Created February 7, 2015 12:48
py2neo 1.6 version of script requesting distance and parent from NCBI Taxonomy Neo4j database
#!/usr/bin/env python
from py2neo import neo4j
import sys
import logging
import argparse
from inspect import getmembers
from pprint import pprint
parser = argparse.ArgumentParser()
parser.add_argument("acc1",

Keybase proof

I hereby claim:

  • I am toniher on github.
  • I am toniher (https://keybase.io/toniher) on keybase.
  • I have a public key whose fingerprint is A3B2 B108 0990 FB04 454E F32E BB7E 8E7B 8D1C C5BE

To claim this, I am signing this object: