Skip to content

Instantly share code, notes, and snippets.

View germanescobar's full-sized avatar

German Escobar germanescobar

View GitHub Profile
@germanescobar
germanescobar / MyPacketProcessor.java
Created November 22, 2012 12:20
SMPP Server Example
public class MyPacketProcessor implements PacketProcessor {
@Override
public void processPacket(SmppRequest packet, ResponseSender responseSender) {
if (packet.isBind()) {
// check the credentials and return the corresponding SMPP command status
Bind bind = (Bind) packet;
responseSender.send( Response.OK ):
@germanescobar
germanescobar / evaluator-service.md
Last active September 15, 2019 11:56
Instructions for the creation of a code evaluation service

Code Evaluator Service

The goal of this project is to create and publish an API that allows users to evaluate code in different programming languages using isolated Docker containers.

Use cases for this project include an online IDE for pair programming, a remote interview tool and evaluation of challenges (like Make it Real), among others.

Before using this service users have to sign up so that they can grab a generated API Key that they have to use to authenticate the requests.

Assuming that the service is published in the domain http://eval.io/, it should be posible to make a POST to the path /v1/eval/<platform> where <platform> is one of the languages or platforms supported.

@germanescobar
germanescobar / ConvertLoop.java
Created October 7, 2017 20:33
ConvertLoop class example in Java
import org.springframework.core.task.TaskExecutor;
// otros imports
public class ConvertLoop {
private TaskExecutor taskExecutor;
public void userRegistered(final User user) {
taskExecutor.execute(new Runnable() {
@Override
public void run() {

La clase Bank sería así:

class Bank
  def initialize
    @accounts = {} # acá vamos a almacenar las cuentas
    @seq = 0 # consecutivo para los ids de las cuentas
  end

  def open(name, initial_balance)

Para hacer algunos ejemplos de herencia, métodos y atributos de clase vamos a modelar un sistema de nómina para una compañía.

Empezamos con una clase Employee de la cual van a extender otras clases:

class Employee
  attr_reader :name, :email, :salary
  
  def initialize(attrs)
    @name = attrs[:name]

El contenido que va dentro de js/app.js es el siguiente:

$(document).ready(function () {
  $(document).on("scroll", onScroll);

  $('nav a[href^="#"]').on('click', function (e) {
    e.preventDefault();
    $(document).off("scroll");
@germanescobar
germanescobar / config.yml
Last active March 27, 2019 15:09
A CircleCI configuration for Express, MongoDB, Puppeteer (testing) and Heroku (deployment)
version: 2
jobs:
build:
docker:
- image: circleci/node:9.2.0-browsers
- image: circleci/mongo:latest
steps:
- checkout
- restore_cache:
var stoneGameII = function(piles) {
return stoneGameRec(piles, 1, [])
};
function stoneGameRec(piles, M, memo) {
if (piles.length === 0) return 0
if (piles.length === 1) return piles[0]
if (piles.length === 2) return piles[0] + piles[1]
const totalStones = piles.reduce((sum, e) => sum + e, 0)
/**
* @param {character[][]} board
* @return {number}
*/
var countBattleships = function(board) {
return countBattleshipsRec(board, 0, 0, false)
};
const mem = {}
function countBattleshipsRec(board, x, y, inAShip) {
var numTilePossibilities = function(tiles) {
return rec(tiles)
};
function rec(tiles) {
if (tiles.length === 1) {
return 1
}
let sum = 0