Skip to content

Instantly share code, notes, and snippets.

Raúl Raja Martínez raulraja

View GitHub Profile
@raulraja
raulraja / ContextUtils.java
Created August 20, 2011 19:59
Simple Event Broadcast with JAVA / Spring AOP / Annotations
/*
* Copyright (C) 2011 47 Degrees, LLC
* http://47deg.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@raulraja
raulraja / gist:1176022
Created August 27, 2011 23:48
Async Operations with ObjectiveC Blocks
/*
* Copyright (C) 2011 47 Degrees, LLC
* http://47deg.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@raulraja
raulraja / NetUtils.java
Created September 14, 2011 20:53
Check if a user has an internet connection for Android
/*
* Copyright (C) 2011 47 Degrees, LLC
* http://47deg.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@raulraja
raulraja / EarthService.java
Created October 21, 2012 21:21
Sample Java Singleton
public class EarthService {
private final static EarthService instance = new EarthService();
private EarthService() {
}
public final static EarthService getInstance() {
return instance;
}
@raulraja
raulraja / Application.java
Created October 22, 2012 10:29
Sample Java Abstract Factory
interface PersistenceService {
void save();
}
class DatabasePersistenceService implements PersistenceService {
public void save() {
// save to database
}
@raulraja
raulraja / Application.java
Created October 22, 2012 10:51
Sample Java Façade
interface SolidObject {
void applyGravity();
void colide(SolidObject other);
}
interface MovingObject {
void run();
void stop();
}
@raulraja
raulraja / PersistenceServiceProxy.java
Created October 22, 2012 13:09
Sample Java Proxy
interface PersistenceService {
Object save(Object obj);
}
class DatabasePersistenceService implements PersistenceService {
@Override
public Object save(Object obj) {
//save to the database
return null;
@raulraja
raulraja / EmailService.scala
Created January 13, 2013 00:18
scala EmailService Actor
package services
import akka.actor.Actor._
import com.typesafe.plugin._
import akka.actor.{Props, OneForOneStrategy, Actor}
import play.api.libs.concurrent.Akka
import play.api.Play.current
case class EmailMessage(subject: String, recipient: String, from: String, text: String, html: String)
@raulraja
raulraja / EmailService.scala
Last active October 19, 2018 06:57
EmailService.scala improved with Exception Handling and Routes
/*
* Copyright (C) 2012 47 Degrees, LLC
* http://47deg.com
* hello@47deg.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@raulraja
raulraja / ScalaVsJava.md
Last active December 13, 2015 20:39
Some sample code regarding Scala Vs Java code verbosity

JAVA

List<Integer> even = new ArrayList<Integer>();
for (String num : numbersAsStrings) {
 int parsedInt = Integer.parseInt(num);
 if (parsedInt % 2 == 0) {
  ints.add(parsedInt);
 }
}