Skip to content

Instantly share code, notes, and snippets.

View hsaputra's full-sized avatar

Henry Saputra hsaputra

View GitHub Profile
You can ssh into the VM by finding the IP (from kubectl config view) and using username "docker" password "tcuser":
ssh docker@192.168.XX.XX
Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white, and blue.
We will use the integers 0, 1, and 2 to represent the color red, white, and blue, respectively.
You must solve this problem without using the library's sort function.
Example 1:
Input: nums = [2,0,2,1,1,0]
Output: [0,0,1,1,2,2]
@hsaputra
hsaputra / gist:96997ab2f50b0a454986
Last active January 26, 2021 06:25
Apache Flink Job execution Flow Sequence
Apache Flink Job Flow from client API to JobGraph
https://cwiki.apache.org/confluence/display/FLINK/Data+exchange+between+tasks
=============================================
WordCount
ExecutionEnvironment#getExecutionEnvironment
ExecutionEnvironment#readTextFile => DataSet<String>
DataSet#flatMap(FlatMapFunction) => FlatMapOperator<T, R>
@hsaputra
hsaputra / gist:5aa1f85db774d880a98d564277d07429
Created January 24, 2021 06:35
Set JAVA_HOME Linux ...
Add it to your ~/.bashrc file"
export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")
class Solution {
public int ladderLength(String beginWord, String endWord, List<String> wordList) {
// check input
if (!wordList.contains(endWord)) {
return 0;
}
// We are going to use BFS to build the graph of the beginWord to endWord using
// all words in the wordList
@hsaputra
hsaputra / gist:ef096819df433834b28da8cbd3beded3
Created September 14, 2017 23:14
GPU NVIDIA remove nouveau driver
remove all nvidia packages ,skip this if your system is fresh installed
sudo apt-get remove nvidia* && sudo apt autoremove
install some packages for build kernel:
sudo apt-get install dkms build-essential linux-headers-generic
now block and disable nouveau kernel driver:
sudo vim /etc/modprobe.d/blacklist.conf
Insert follow lines to the blacklist.conf:
@hsaputra
hsaputra / gist:6c5641aca130d3bf4d73e3e63197c9b5
Created March 19, 2019 16:00
Docker - remove all containers based on container id
# for each container ID use the docker "rm" command to remove/delete the container
!for cid in $(docker ps -a | awk '{print $1}' | tail -n +2);do docker rm $cid; done
@hsaputra
hsaputra / gist:afcabb8b5f38654a976fb05e82716c73
Created March 19, 2019 15:59
Docker - generate a list of container ID from the docker ps command
# generate a list of container ID from the docker ps command
!docker ps -a | awk '{print $1}' | tail -n +2
/**
* Definition for an interval.
* public class Interval {
* int start;
* int end;
* Interval() { start = 0; end = 0; }
* Interval(int s, int e) { start = s; end = e; }
* }
*/
class Solution {
@hsaputra
hsaputra / gist:d2cc3a1fbe8cbb106b0d98679272d8c3
Last active November 10, 2018 17:41
33. Search in Rotated Sorted Array
class Solution {
// [4,5,6,7,0,1,2,3]
// [6,7,0,1,2,3,4,5]
public int search(int[] nums, int target) {
if (nums == null || nums.length == 0) {
return -1;
}
final int numsLen = nums.length;