Skip to content

Instantly share code, notes, and snippets.

View sajithdilshan's full-sized avatar

Sajith Edirisinghe sajithdilshan

View GitHub Profile
import React, { Component } from 'react';
import Alice from './Alice';
class App extends Component {
constructor() {
super();
this.state = {
greeting: "Hello World!",
parentMessage: "Hello Alice!"
public static class TokenizerMapper extends Mapper<Object, Text, Text, IntWritable> {
private static final Pattern pattern = Pattern.compile("\"([^\"]*)\"");
private final static IntWritable one = new IntWritable(1);
private Text word = new Text();
public void map(Object key, Text value, Context context) throws IOException, InterruptedException {
Matcher matcher = pattern.matcher(value.toString());
if (matcher.find()) {
word.set(matcher.group(0));
context.write(word, one);
public static class IntSumReducer extends Reducer<Text, IntWritable, Text, IntWritable> {
private IntWritable result = new IntWritable();
public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
int sum = 0;
for (IntWritable val : values) {
sum += val.get();
}
result.set(sum);
context.write(key, result);
public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
conf.set("fs.defaultFS", "hdfs://localhost:9000");
Job job = Job.getInstance(conf, "word count");
job.setJarByClass(VisitorPathCount.class);
job.setMapperClass(TokenizerMapper.class);
job.setCombinerClass(IntSumReducer.class);
job.setReducerClass(IntSumReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
"GET /apple-touch-icon.png HTTP/1.1" 1
"GET /assets/css/style.css HTTP/1.1" 2
"GET /assets/data-tables/icons.css HTTP/1.1" 2
"GET /assets/data-tables/index.css HTTP/1.1" 2
"GET /assets/data-tables/themes/material.css HTTP/1.1" 3
"GET /assets/date-range-picker/daterangepicker.min.css HTTP/1.1" 2
"GET /assets/date-range-picker/daterangepicker.min.css.map HTTP/1.1" 16
"GET /assets/date-range-picker/daterangepicker.min.js HTTP/1.1" 2
"GET /assets/date-range-picker/daterangepicker.min.js.map HTTP/1.1" 15
"GET /assets/date-range-picker/moment.min.js HTTP/1.1" 4
import React from "react";
export default class ButtonComponent extends React.Component {
render() {
return (
<div>
<button className="color-button">Red</button>
<button className="color-button">Blue</button>
</div>
import React from "react";
export default class ColorComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
color: "lightgrey"
}
}
import React from "react";
import ButtonComponent from "./components/ButtonComponent";
import ColorComponent from "./components/ColorComponent";
export default class App extends React.Component {
render() {
return (
<div>
<ButtonComponent/>
.color-container {
width: 400px;
height: 400px;
}
.color-button {
width: 50px;
height: 20px;
margin: 10px;
background-color: #dddddd;
import {Dispatcher} from "flux";
export default new Dispatcher();