Skip to content

Instantly share code, notes, and snippets.

View pingsutw's full-sized avatar
🏠
Working from home

Kevin Su pingsutw

🏠
Working from home
View GitHub Profile
@pingsutw
pingsutw / WordCount1.java
Last active February 14, 2020 17:36
Mapreduce Word count example (sort by word frequency)
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.StringTokenizer;
@pingsutw
pingsutw / sort.java
Created February 14, 2020 03:46
Mapreduce sort by word frequency
import java.nio.ByteBuffer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.IntWritable.Comparator;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.WritableComparator;
import org.apache.hadoop.mapreduce.Job;
@pingsutw
pingsutw / generate_card.java
Created February 14, 2020 17:33
Generate random deck card
import java.util.Scanner;
import java.util.Random;
public class generate_card {
public static void main (String[] args) {
Scanner scan = new Scanner (System.in);
int num_decks = scan.nextInt();
int num_perDecks = scan.nextInt();
//String suits[] = {"H","D","C","S"};
String suits[] = {"\u2661", "\u2662", "\u2663", "\u2660"};
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.StringTokenizer;
@pingsutw
pingsutw / distributed_mnist.py
Created February 28, 2020 03:12
Distributed train mnist
# tensorflow 2 supported
# using MultiWorkerMirroredStrategy
# Need to install tf-nightly
# https://www.tensorflow.org/tutorials/distribute/multi_worker_with_keras
from __future__ import absolute_import, division, print_function, unicode_literals
import numpy as np
import tensorflow_datasets as tfds
import tensorflow as tf
tfds.disable_progress_bar()
@pingsutw
pingsutw / codejam.cpp
Last active April 5, 2020 06:45
Code Jam Template - Templates for Google Code Jam contest
#include <bits/stdc++.h>
using namespace std;
#define rep(i, x, y) for (__typeof(x) i = x; i <= y; i++)
#define repi(i, x, y) for (__typeof(x) i = x; i >= y; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(x, y) memset(x, y, sizeof(y))
@pingsutw
pingsutw / tf_job_mnist.yaml
Created April 21, 2020 03:47
kubeflow - TensorFlow with init container
apiVersion: "kubeflow.org/v1"
kind: "TFJob"
metadata:
name: "mnist"
namespace: submarine
spec:
cleanPodPolicy: None
initContainers:
- name: init-mydb
image: busybox:1.28
@pingsutw
pingsutw / submarineAPI.yaml
Last active April 28, 2020 08:42
Submarine Swagger API definition
swagger: "2.0"
info:
description: "The Submarine REST API allows you to create, list, and get experiments. The API is hosted under the /v1/jobs route on the Submarine server. For example, to list experiments on a server hosted at http://localhost:8080, access http://localhost:8080/api/v1/jobs/status"
version: "1.0.0"
title: "Submarine Job API"
termsOfService: "http://swagger.io/terms/"
contact:
email: "submarine-dev@submarine.apache.org"
license:
name: "Apache 2.0"
@pingsutw
pingsutw / swagger.yaml
Created April 28, 2020 10:24
Swagger YAML generated by submarine
swagger: '2.0'
info:
description: 'The Submarine REST API allows you to create, list, and get experiments. The API is hosted under the /v1/jobs route on the Submarine server. For example, to list experiments on a server hosted at http://localhost:8080, access http://localhost:8080/v1/jobs/status'
version: 1.0.0
title: ''
termsOfService: 'http://swagger.io/terms/'
contact:
email: submarine-dev@submarine.apache.org
license:
name: Apache 2.0
@pingsutw
pingsutw / experiment.yaml
Last active May 4, 2020 18:56
Submarine Experiment spec - swagger 2.0
swagger: "2.0"
info:
description: "The Submarine REST API allows you to create, list, and get experiments. The API is hosted under the /v1/jobs route on the Submarine server. For example, to list experiments on a server hosted at http://localhost:8080, access http://localhost:8080/api/v1/jobs/"
version: "1.0.0"
title: "Submarine Experiment API"
termsOfService: "http://swagger.io/terms/"
contact:
email: "submarine-dev@submarine.apache.org"
license:
name: "Apache 2.0"