Skip to content

Instantly share code, notes, and snippets.

View ny83427's full-sized avatar
JUST DO IT

Nathanael Yang ny83427

JUST DO IT
View GitHub Profile
@ny83427
ny83427 / boxstarter-for-java-dev-env
Last active December 29, 2018 01:21
Setup SE500 development environment
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions
Enable-RemoteDesktop
cinst intellijidea-community
cinst jdk11
cinst jdk8
cinst git
cinst notepadplusplus
cinst vscode
cinst beyondcompare
@ny83427
ny83427 / TreeNode.java
Last active December 31, 2018 19:10
Leetcode Weekly Contest 117 Q1 and Q2 My Solution
import java.util.Stack;
public class TreeNode {
public int val;
public TreeNode left;
public TreeNode right;
public TreeNode(int x) {
val = x;
}
@ny83427
ny83427 / java-dev-env-cmd.bat
Last active January 11, 2019 10:15
Setup Java Development Environment Using Chocolatey
@echo off
:: install Chocolatey, please make sure you are running cmd as administrator
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
:: install necessary components of Java development environment and some useful stuff
cinst intellijidea-community git jdk8 jdk11 vscode notepadplusplus eclipse netbeans-jse maven gradle everything f.lux -y
@ny83427
ny83427 / Audience.java
Created January 13, 2019 00:26
Play java audio file
/**
* Initialize JFX toolkit if you are not running in JavaFX GUI environment
* It supports mp3, wav and is much easier to use
*/
void cheer() {
PlatformImpl.startup(() -> {
Media hit = new Media(new File("audios/cheer.mp3").toURI().toString());
MediaPlayer mediaPlayer = new MediaPlayer(hit);
mediaPlayer.play();
});
@ny83427
ny83427 / Sample.java
Created January 18, 2019 20:08
Double Buffer Avoid Flashing
private Image bgImage;
@Override
public void update(Graphics g) {
if (bgImage == null) bgImage = this.createImage(WIDTH, HEIGHT);
Graphics bg = bgImage.getGraphics();
bg.setColor(Color.BLACK);
bg.fillRect(0, 0, WIDTH, HEIGHT);
this.paintComponent(bg);
}
@ny83427
ny83427 / inst-oracle-jdk13-ubuntu.sh
Created February 25, 2020 23:23
install-oracle-jdk13-ubuntu
# auto accept oracle license agreement
echo oracle-java13-installer shared/accepted-oracle-license-v1-2 select true | sudo /usr/bin/debconf-set-selections
# install oracle jdk13 and set environment variables
sudo add-apt-repository ppa:linuxuprising/java -y
sudo apt-get update
sudo apt-get install oracle-java13-installer -yq
sudo apt-get install oracle-java13-set-default -yq
# set JAVA_HOME variable and link jdk13 to default location also
@ny83427
ny83427 / install-nexus.sh
Last active March 25, 2020 20:06
Quick and dirty script to setup nexus at Ubuntu
# download 3.21.2-03 or latest version if you want: latest-unix.tar.gz
wget https://sonatype-download.global.ssl.fastly.net/nexus/3/nexus-3.21.2-03-unix.tar.gz
tar xvzf nexus-3.21.2-03-unix.tar.gz
# if you use latest-unix.tar.gz the extracted directory name might be different
cd nexus-3.21.2-03/bin
# start nexus in background and check status
./nexus start
./nexus status
# access http://localhost:8081 with admin/admin123
@ny83427
ny83427 / inst-maven-3.6.0.sh
Created January 22, 2019 22:13
Install Maven 3.6.0 at Ubuntu 14.04
wget https://www-us.apache.org/dist/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.tar.gz
sudo tar xf apache-maven-*.tar.gz -C /opt
sudo ln -s /opt/apache-maven-3.6.0 /opt/maven
sudo nano /etc/profile.d/maven.sh
# commit these 4 lines
export JAVA_HOME=/usr/lib/jvm/default-java
export M2_HOME=/opt/maven
export MAVEN_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}
sudo chmod +x /etc/profile.d/maven.sh