Skip to content

Instantly share code, notes, and snippets.

Diego Alvarez d1egoaz

  • Shopify
  • Vancouver - Canada
Block or report user

Report or block d1egoaz

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
@d1egoaz
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>
<bean id="miclaseDao" class="com.d1egoaz.misuperproyecto.dao.MiclaseDaoImpl">
<property name="jdbcDataSource">
<bean factory-bean="miDataSourceProvider" factory-method="getDataSource" />
</property>
</bean>
View git-mergetool-winmerge-setup.sh
#!/bin/sh
#
# 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 https://gist.github.com/1010253
@d1egoaz
d1egoaz / recoverAnyFailure
Last active Aug 29, 2015
recoverAnyFailure
View recoverAnyFailure
// esto en Command
val recoverAnyFailure = new PartialFunction[Throwable, Either[Any, Failure]] {
def apply(d: Throwable) = d match {
case e: SQLException =>
e.printStackTrace()
logger.error("SQLException -> código: " + e.getErrorCode + ", mensaje: " + e.getMessage)
Left(Failure(None, None, Translate("ERROR_INESPERADO"), None, None, FailureType.DatabaseFailure))
case e: Throwable =>
e.printStackTrace()
logger.error("Exception -> mensaje: " + e.getMessage)
@d1egoaz
d1egoaz / NaiveSocialAggregatorScala
Last active Aug 29, 2015
NaiveSocialAggregatorScala
View NaiveSocialAggregatorScala
package co.s4n.example.sa
import scala.concurrent.{ExecutionContext, Future}
class NaiveSocialAggregatorScala {
def amigos()(implicit ec: ExecutionContext):Future[List[String]] = {
import co.s4n.sa.SocialWeb20Adapter
import scala.collection.JavaConverters._
@d1egoaz
d1egoaz / TestNaiveSocialAggregatorScalaTest
Last active Aug 29, 2015
TestNaiveSocialAggregatorScalaTest
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
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");
next();
});
@d1egoaz
d1egoaz / ubuntu_kernel_3.19_x64_install.sh
Created Feb 9, 2015
ubuntu kernel 3.19 x64 install script
View ubuntu_kernel_3.19_x64_install.sh
#!/bin/bash
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.19-vivid/linux-headers-3.19.0-031900-generic_3.19.0-031900.201502091451_amd64.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.19-vivid/linux-headers-3.19.0-031900_3.19.0-031900.201502091451_all.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.19-vivid/linux-image-3.19.0-031900-generic_3.19.0-031900.201502091451_amd64.deb
sudo dpkg -i linux-headers-3.19.0-*.deb linux-image-3.19.0-*.deb
View isPalindrome
def isPalindrome(testString: String): Boolean = {
val s: String = testString.toLowerCase.replaceAll("\\P{Alnum}", "");
s == s.reverse
}
// test
isPalindrome("race car")
isPalindrome("racecar")
isPalindrome("race. Car")
isPalindrome("ana")
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 sequencev2
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 None :: _ => None
case Some(h) :: t => innerAux(t, tmp :+ h)
}
}
You can’t perform that action at this time.