Skip to content

Instantly share code, notes, and snippets.

import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
public class Enigma{
public static String readEnigma(String path) throws Exception{
StringBuilder letras = new StringBuilder();
//abrir el archivo, podría no encontrarlo
FileInputStream in = new FileInputStream(path);
import java.util.HashMap;
import java.util.ArrayList;
class Carta{
String palo;
int num;
public Carta(String palo,int num){
this.palo = palo;
this.num = num;
}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TupleSections #-}
module Poptics where
import Prelude hiding (traverse)
import Control.Category ((>>>))
import Control.Applicative (liftA2, Const (..))
import Control.Arrow ((&&&), (|||), (***))
newtype State s a = State { run :: s -> (a,s)}
@lfborjas
lfborjas / Baraja.java
Created October 26, 2010 22:05
Solución a la segunda parte del examen, con pruebas automatizadas agregadas.
package parte2;
import java.util.ArrayList;
import java.util.Collections;
/**
* @author lfborjas
*/
public class Baraja {
public static String[] palos={"diamantes", "tréboles", "corazones", "espadas"};
@lfborjas
lfborjas / basic.js
Created December 1, 2010 19:55
ejemplos de javascript
/*
* Los elementos primitivos de javascript son
* números
* strings
* booleans
* nulidades: `undefined`(implícita) y `null` (explícita)
*Los medios de combinación: arreglos y objetos.
@lfborjas
lfborjas / gist:817504
Created February 8, 2011 23:12
Filter even numbers in a list; fork it for maximum fun!
#these are meant to be run in a REPL, and the java one in beanshell of something of the sort:
#ruby
[1,2,3,4].select{ |x| x.even? }
#python
[x for x in [1,2,3,4] if not x%2]
#or, more norvingly
filter(lambda x: not x%2, [1,2,3,4])
#clojure
@lfborjas
lfborjas / postgres-upsert.sql
Created February 26, 2021 23:47
Upsert that always returns in Postgres
-- :name insert-or-get-image! :<! :1
/* :doc insert an image, or retrieve existing, and return the id, uri, and
public URL as determined by the provided `:bucket` and `:images-host`.
*/
WITH new_img AS (
INSERT INTO image (uri, fmt, size, device_id, os_version_id)
VALUES (:uri, :fmt, :size, :device-id, :os-version-id)
ON CONFLICT (uri) DO NOTHING
RETURNING id, uri,
gcs_uri_to_public_url(uri, COALESCE(:bucket, ''), COALESCE(:images-host, ''))
@lfborjas
lfborjas / Dockerfile
Created December 14, 2020 01:00 — forked from TimWSpence/Dockerfile
Optimized multistage Dockerfile for Haskell Stack builds
# Loosely based on https://www.fpcomplete.com/blog/2017/12/building-haskell-apps-with-docker
FROM fpco/stack-build:lts-13.27 as dependencies
RUN mkdir /opt/build
WORKDIR /opt/build
# GHC dynamically links its compilation targets to lib gmp
RUN apt-get update \
&& apt-get download libgmp10
RUN mv libgmp*.deb libgmp.deb
package ejercicios;
import java.util.ArrayList;
import java.util.Random;
import java.util.Arrays;
public class Conjuntos{
private static ArrayList<String> union(ArrayList<String> primero, ArrayList<String> segundo){
ArrayList<String> retVal = new ArrayList<String>(primero);
for(String worte: segundo){
if(!primero.contains(worte))
*Programa que genera un arreglo con tamaño aleatorio de enteros aleatorios
e imprime un histograma de frecuencias
*/
package ejercicios;
//clase de java para generar números aleatorios:
import java.util.Random;
//sirve para representar colecciones tabulares
import java.util.HashMap;
//contiene distintas utilidades para colecciones