Skip to content

Instantly share code, notes, and snippets.

Diego Alvarez d1egoaz

  • Shopify
  • Vancouver - Canada
View GitHub Profile
View sequence
def sequence[A](a: List[Option[A]]): Option[List[A]] = {
def innerAux[A](b: List[Option[A]], tmp: List[A]): Option[List[A]] = {
b match {
case Nil => Some(tmp)
case h :: t =>
h match {
case Some(v) => innerAux(t, v :: tmp)
case None => None
View isPalindrome
def isPalindrome(testString: String): Boolean = {
val s: String = testString.toLowerCase.replaceAll("\\P{Alnum}", "");
s == s.reverse
// test
isPalindrome("race car")
isPalindrome("race. Car")
d1egoaz /
Created Feb 9, 2015
ubuntu kernel 3.19 x64 install script
sudo dpkg -i linux-headers-3.19.0-*.deb linux-image-3.19.0-*.deb
d1egoaz / node express cors support
Created Oct 28, 2014
Little node express app to add proxy layer to make request to non cors support enabled endpoints (only for testing purpose)
View node express cors support
var express = require('express');
var request = require('request');
var app = express();
app.all('*', function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
d1egoaz / TestNaiveSocialAggregatorScalaTest
Last active Aug 29, 2015
View TestNaiveSocialAggregatorScalaTest
import java.util.concurrent.Executors
import org.scalatest.FunSuite
import scala.concurrent.{ExecutionContext, Await}
import scala.concurrent.duration._
class TestNaiveSocialAggregatorScalaTest extends FunSuite {
private val executionService = Executors.newFixedThreadPool(4)
d1egoaz / NaiveSocialAggregatorScala
Last active Aug 29, 2015
View NaiveSocialAggregatorScala
import scala.concurrent.{ExecutionContext, Future}
class NaiveSocialAggregatorScala {
def amigos()(implicit ec: ExecutionContext):Future[List[String]] = {
import scala.collection.JavaConverters._
d1egoaz / recoverAnyFailure
Last active Aug 29, 2015
View recoverAnyFailure
// esto en Command
val recoverAnyFailure = new PartialFunction[Throwable, Either[Any, Failure]] {
def apply(d: Throwable) = d match {
case e: SQLException =>
logger.error("SQLException -> código: " + e.getErrorCode + ", mensaje: " + e.getMessage)
Left(Failure(None, None, Translate("ERROR_INESPERADO"), None, None, FailureType.DatabaseFailure))
case e: Throwable =>
logger.error("Exception -> mensaje: " + e.getMessage)
# This script will make WinMerge your default tool for diff and merge.
# It must run inside git bash (on Windows)
# If you experience path issues you should give a try to the gist
# created by markusobrist at
d1egoaz / inject_beanmethod_into_beanproperty.xml
Created May 9, 2012
Inyectar el resultado de un método como una propiedad de un bean en Spring
View inject_beanmethod_into_beanproperty.xml
<bean id="miDataSourceProvider" class="com.algunnamespace.sql.DataSourceProvider">
<bean id="miclaseDao" class="com.d1egoaz.misuperproyecto.dao.MiclaseDaoImpl">
<property name="jdbcDataSource">
<bean factory-bean="miDataSourceProvider" factory-method="getDataSource" />
You can’t perform that action at this time.