Skip to content

Instantly share code, notes, and snippets.

View eloipuertas's full-sized avatar

Eloi Puertas eloipuertas

View GitHub Profile
@eloipuertas
eloipuertas / TwoThreadsDemo.java
Last active March 6, 2018 19:08
SimpleThreadDemo.java
class SimpleThread implements Runnable {
public String name = "";
public SimpleThread(String str) {
name = str;
}
public String getName(){
return name;
}
@eloipuertas
eloipuertas / DateClient.java
Last active March 6, 2024 15:17
DataServer with Threads
// source: http://java.sun.com/developer/technicalArticles/ALT/sockets/
import java.io.*;
import java.net.*;
import java.util.*;
public class DateClient {
public static void main(String argv[]) {
ObjectOutputStream oos = null;
ObjectInputStream ois = null;
from pyspark import SparkContext
from pyspark.sql.types import *
sc = SparkContext ('local[*]','pyspark')
lines = sc.textFile("pride_and_prejudice.txt")
words = lines.flatMap(lambda x: x.split(" "))
word_count = (words.map(lambda x: (x,1)).reduceByKey(lambda x,y: x+y))
word_count.saveAsTextFile("output")
import java.io.IOException;
import java.net.*;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Client {
public static void main(String[] args) {
import java.net.*;
import java.io.*;
public class MulticastPeer{
public static void main(String args[]){
// args give message contents and destination multicast group (e.g. "228.5.6.7")
System.setProperty("java.net.preferIPv4Stack", "true");
MulticastSocket s =null;
try {
InetAddress group = InetAddress.getByName(args[1]);
s = new MulticastSocket(6789);
@eloipuertas
eloipuertas / WordCount.java
Created May 18, 2016 14:26
Hadoop WordCount example
package org;
import java.io.IOException;
import java.util.*;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.conf.*;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapred.FileInputFormat;

Keybase proof

I hereby claim:

  • I am eloipuertas on github.
  • I am eloipuertas (https://keybase.io/eloipuertas) on keybase.
  • I have a public key whose fingerprint is C52B DA22 ACBE A120 4E42 CE40 979A BF1B 22E8 9629

To claim this, I am signing this object:

@eloipuertas
eloipuertas / HTTPClient.py
Created March 31, 2016 10:13
SimpleHTTPClientPython
import urllib2
f = urllib2.urlopen('http://www.python.org/')
print f.read().decode('utf-8')
import java.net.*;
import java.io.*;
public class URLBrowser {
// An application which uses a URL object to retreive
// the text contents of a web page.
// These command line arguments are expected, in order:
// <host name of the HTTP server>
// <port number of the HTTP server>
/*************************************************************************
* Compilation: javac GuiChat.java
* Execution: java GuiChat name host
*
*************************************************************************/
import java.awt.*;
import java.awt.event.*;
import javax.swing.JFrame;