Skip to content

Instantly share code, notes, and snippets.

Juan Manuel Fernandez juanmf

Block or report user

Report or block juanmf

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
View gist:87f71cfc3c7c00471eafcf318485e314
import lombok.AllArgsConstructor;
import org.junit.Test;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
View Spark-WordCount-Java8.java
package com.mycompany;
/**
* Created by juanmf on 15/07/17.
*/
import java.util.Arrays;
import java.util.stream.Collectors;
import org.apache.spark.api.java.*;
import org.apache.spark.SparkConf;
@juanmf
juanmf / daily-exchange.js
Created Mar 4, 2017
Webtask.io little hack
View daily-exchange.js
/**
* This script can be automatically triggered with IFTTT Stocks trigger and should
* be called with the following query string params:
*
* inputCurrency={{InputCurrency}}
* outputCurrency={{OutputCurrency}}
* exchangeRate={{ExchangeRate}}
* infoUrl={{InfoUrl}}
* checkTime={{CheckTime}}
*
@juanmf
juanmf / MutableBigInteger.java
Last active Mar 24, 2016
MutableBigInteger
View MutableBigInteger.java
/*
* The MIT License
*
* Copyright 2016 juan.fernandez.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@juanmf
juanmf / Stopwatch.java
Last active Mar 24, 2019
Simple Stopwatch that keeps a cache of running tasks.
View Stopwatch.java
import java.util.Collections;
import java.util.Map;
import java.util.TreeMap;
/**
* Usage:
*
* Stopwatch.start("watchName");
* ...
View ProcessRolesSubscriber.php
<?php
namespace Application\ProcessBundle\Subscriber;
//Since Doctrine 2.4
//use Doctrine\Common\Persistence\Event\LifecycleEventArgs;
//use Doctrine\Common\Persistence\Event\PreUpdateEventArgs;
use Symfony\Bridge\Monolog\Logger as SfLogger;
use Doctrine\Common\EventSubscriber;
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
View gist:8f75706af3ec7ed74918
#The Config File
# The tool: https://github.com/juanmf/RedmineIssueImporter
#Use the following config file format to import sheets into redmine. So far it creates Issues,
#with custom fields, but it's extensible to add users, etc..
################################################################################
# Run customization
View Symfony2FormCollectionAllowAddPrototypeClonner.js
/**
* Recursive Prototype Clonner:
* it relies on the following data structure:
* <someAncestor data-allow-add="true"> ...
* <button class="" data-add="add"
* data-add-prototype-node="JQ selector relative to $button.closest('[data-allow-add]'). Will be parameter of $obj.find($selector)"
* data-add-prototype-name="<?php echo $prototypeName; ?> optional, defauts to __name__"
* data-add-append-node="%data-add-prototype-node% | JQ selector relative to $button.closest('[data-allow-add]').
* Will be parameter of $obj.find($selector)"
* data-add-wrapper="html to wrap the cloned item before appending e.g. <li>__PROTOTYPE-CONTENT__</li>"
View mediator.js
/*
* I needed it 'cause I have a generic js to add embeded subForms to a Form
* appending the prototype upon AddButton JQuery click event. So to add event
* bindings to one of the controls generated out of the prototype template, which
* is unknown to the js that adds it, I fire a message like "prototype_just_added"
* and the specific js catches it and binds the event.
*/
/*
* MediatorPatter implementaton to allow for some behavior extensions.
You can’t perform that action at this time.