Skip to content

Instantly share code, notes, and snippets.

@JoeyAndres
JoeyAndres / hadoop.sh
Created Oct 23, 2017
/etc/profile.d hadoop env script.
View hadoop.sh
# Hadoop
export HADOOP_HOME=/opt/hadoop/hadoop-2.7.4
export PATH=$PATH:$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
View hadoop.service
[Unit]
Description=Hadoop start/stop
[Service]
User=hadoop
Group=hadoop
Type=oneshot
ExecStart=/opt/hadoop/hadoop-service.sh start
ExecStop=/opt/hadoop/hadoop-service.sh stop
RemainAfterExit=yes
View hadoop-service.sh
#!/bin/bash
start() {
source "/etc/profile.d/hadoop.sh"
start-dfs.sh
start-yarn.sh
}
stop() {
View OverallTeamRaceResultReducer.java
package HadoopF1.OverallTeamRaceResult;
import java.io.IOException;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
public class OverallTeamRaceResultReducer extends Reducer<Text, IntWritable, Text, IntWritable> {
View OverallTeamRaceResultMapper.java
package HadoopF1.OverallTeamRaceResult;
import java.io.IOException;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import HadoopF1.ResultsRecord;
@JoeyAndres
JoeyAndres / f1-results.py
Last active Oct 22, 2017
Gets all the F1 race results from 1950 to 2017. The results are flatten so that they are easily utilized in mapreduce.
View f1-results.py
#!/usr/bin/python
import sys
import urllib2
import time
import json
def get_results(output_dir):
for year in range(1950, 2017 + 1):
for rnd in range(1, 50):
View CustomSTLContainer.cpp
template <class T, class A = std::allocator<T> >
class X {
public:
typedef A allocator_type;
typedef typename A::value_type value_type;
typedef typename A::reference reference;
typedef typename A::const_reference const_reference;
typedef typename A::difference_type difference_type;
@JoeyAndres
JoeyAndres / ConcatenateArray.cpp
Created Dec 28, 2016
C++ code for concatenating array.
View ConcatenateArray.cpp
#include <array> // std::array
#include <algorithm> // std::copy
using std::array;
/**
* Concatenates array.
*
* @tparam T Type of data stored in array.
* @tparam D1 Dimension of first array.
@JoeyAndres
JoeyAndres / uri.js
Created Mar 13, 2016 — forked from jlong/uri.js
URI Parsing with Javascript
View uri.js
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"