Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Juan Julián Merelo Guervós JJ

🏠
Working from home
Block or report user

Report or block JJ

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@JJ
JJ / equipo.xml
Created Jul 13, 2011
Pretty-print XML files with user-specified colors and indents
View equipo.xml
?xml version="1.0"?>
<?xml-stylesheet href="tienda0.xsl" type="text/xsl"?>
<equipo>
<jugador posicion='portero'>Araña</jugador>
<jugador posicion='delantero'>Cazagoles</jugador>
</equipo>
@JJ
JJ / csv_to_net.pl
Created Oct 24, 2011
Convert CSV files to Pajek .net format. Takes file with two columns as argument; every row indicates a connection from agent in column A to agent in Column B. Outputs a file with the same root and .net extension in .net format, which can be used in Pajek
View csv_to_net.pl
#!/usr/bin/perl
use strict;
use warnings;
use File::Slurp qw(read_file);
my $csv = shift || die "No defaults; $0 <csvfile>\n";
my $content = read_file($csv) || die "Can't read file $csv: $!\n";
@JJ
JJ / jquery-test.js
Created Jan 25, 2012
Prueba con JQuery para el taller de Ajax de la OSLUGR. Un ejemplo mínimo de uso de Ajax con JQuery
View jquery-test.js
$(function(){
$("a.ajax").click((function(){
$.get($(this).attr('href'), function(data){
alert("Ya");
})
.success(function(data){
alert( 'Lo hise' )})
.error(function(data){
alert( 'Pos no' )})
.complete(function(data){
@JJ
JJ / compare_strings_mastermind.c
Last active Dec 10, 2015
Compare two strings returning the number of symbols in the correct position ("blacks") and the number of symbols in the wrong position ("whites"), MasterMind style
View compare_strings_mastermind.c
#include <stdio.h>
#include <string.h>
// with help from http://www.eskimo.com/~scs/cclass/notes/sx13.html
int main( int argc, char *argv[] )
{
char *hidden = argv[1];
char *target = argv[2];
char colors = atoi( argv[3] );
printf( "Hidden %s target %s colors %d\n", hidden, target, colors);
@JJ
JJ / citations.user.js
Created Apr 20, 2013
GreaseMonkey script that puts on top of the citation graph the actual number of citations per year; works on the Google Citations page. In old versions of Chrome and Chromium this should work without a problem. In new versions you'll have to get out of your way to install it, so don't bother and just switch to Firefox and install the GreaseMonke…
View citations.user.js
// ==UserScript==
// @name gcitations
// @namespace http://merelo.net/gmscripts
// @description Compute number of citations per year in Google Citations
// @include http://scholar.google.com/citations*
// ==/UserScript==
var imgs = document.getElementsByTagName('img');
var my_url;
@JJ
JJ / git-hooks.pl
Created Aug 26, 2013
Git post-commit hook for modifying .md files to work with gh-pages and just copy other files, like .png, .css and so on.
View git-hooks.pl
#!/usr/bin/env perl
use strict;
use warnings;
use v5.14;
use Git::Hooks;
use File::Slurp qw(read_file write_file);
my $layout_preffix=<<EOT;
---
@JJ
JJ / node-and-npm-in-30-seconds.sh
Last active Jan 3, 2016 — forked from isaacs/node-and-npm-in-30-seconds.sh
Installing node in a very raw box (like the one provided by docker). It will take a bit more than 30 seconds, somehow
View node-and-npm-in-30-seconds.sh
#Problem with this is that it needs lots of installed stuff, so I'll put it here
# sudo or admin shell is presupposed
apt-get install make curl python-setuptools gcc g++
#Maybe you can safely supress make and gcc from here, since they are dependencies of g++
#Then you can proceed to the original set
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir /usr/local
mkdir ~/node-latest-install
@JJ
JJ / chef-solo.sh
Created Jan 24, 2014
Provisioning chef-solo for ArchLinux 2013
View chef-solo.sh
pacman -S ruby make gcc
gem install chef ohai --no-user-install
@JJ
JJ / wilcoxon-ga.chunk.pl
Last active Aug 29, 2015
Applying Wilcoxon-comparison based partial order to an evolutionary algorithm
View wilcoxon-ga.chunk.pl
for my $p ( @pop ) {
push(@{$p->{'_fitness_memory'}}, $noisy->apply( $p ));
$p->Fitness($comparisons);
}
for my $i (1..$comparisons) {
my @copy_of_population = @pop;
while( @copy_of_population ) {
my $first = splice( @copy_of_population, rand( @copy_of_population ), 1 );
my $second = splice( @copy_of_population, rand( @copy_of_population ), 1 );
my $aov = Statistics::ANOVA->new();
@JJ
JJ / install_Git.pm.md
Last active Jan 6, 2017
Install Git.pm in a perlbrew installation
View install_Git.pm.md

Git.pm is a module that comes with git and can't be installed with the usual cpan magic. If you switch to perlbrew you'll get a Can't locate Git.pm error when you try to run it, so you need to install it explicitly if you want to use it in your own installation, mainly if you use perlbrew I use it in my novels for post-commit hooks, so here's what you have to do to have it available in your programs

bash$ cp /usr/share/perl5/Git.pm ~/perl5/perlbrew/perls/perl-5.x.y/lib/site_perl/5.x.y

you'll have to change x.y by the perl version you're actually using. You'll also need Error.pm, so do

bash$ cp /usr/share/perl5/Error.pm ~/perl5/perlbrew/perls/perl-5.x.y/lib/site_perl/5.x.y

And that's it!

You can’t perform that action at this time.