Skip to content

Instantly share code, notes, and snippets.

View tofuninjah's full-sized avatar
🖤

Chung Kang tofuninjah

🖤
View GitHub Profile
@tofuninjah
tofuninjah / Streams.java
Last active June 9, 2020 20:48
Streams Java Examples
import java.util.Arrays;
import java.util.*;
import java.util.stream.*;
import java.util.regex.*;
import java.util.function.Function;
class Main {
public static void main(String[] args) {
List.of("This ", "is ", "created ", "by ", "List.of().stream() ")
@tofuninjah
tofuninjah / TestUtils
Created December 4, 2019 22:44
TestUtils
package com.nrg.xoom;
import java.lang.reflect.Field;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class TestUtils {
static final Logger logger = LogManager.getLogger(TestUtils.class.getName());
@tofuninjah
tofuninjah / git_fetch_pull_all_subfolders.sh
Created April 22, 2019 19:17 — forked from mnem/git_fetch_pull_all_subfolders.sh
Simple bash script for fetching and pulling all repos in the executed folder to the latest of the branch they are on
#!/bin/bash
################
# Uncomment if you want the script to always use the scripts
# directory as the folder to look through
#REPOSITORIES="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
REPOSITORIES=`pwd`
IFS=$'\n'
@tofuninjah
tofuninjah / ajax
Last active April 22, 2019 04:01
ajax
<div id="output">Hello World</div>
<script>
$('#output').click(function(){
$.ajax({
dataType:"json",
url:'https://jsonplaceholder.typicode.com/posts/1',
success:success
})
.done(function(){console.log('DONE')})
})
@tofuninjah
tofuninjah / mockito-basic-example
Created March 29, 2019 13:57
Mockito - Example
public class Example {
private Delegate delegate;
Example(Delegate delegate) {
this.delegate = delegate;
}
public void doIt() {
delegate.execute();
@tofuninjah
tofuninjah / git-remote-prune
Last active March 27, 2019 18:58
Git Remote Prune
$ git remote prune origin --dry-run
$ git remote prune origin [to execute]
### To show branches on remote (should now be pruned of outdated branches)
$ git branch -r
origin/CI/develop-CI
origin/HEAD -> origin/master
origin/develop
origin/features/ESIID
@tofuninjah
tofuninjah / h2
Last active March 23, 2019 04:24
h2-application.properties
spring.h2.console.enabled=true
spring.h2.console.path=/h2
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver
spring.jpa.show-sql = true
@tofuninjah
tofuninjah / JavaSnippets
Last active March 6, 2019 21:52
Java Snippets
/*
* Get raw json and output to string
*/
System.out.println(res.getBody().asString());
/*
* Read Excel Worksheet
*/
package Framework.ExcelDriven;
// function to remove all occurrences
// of an element from an array
public static int[] removeElements(int[] arr, int key)
{
// Move all other elements to beginning
int index = 0;
for (int i=0; i<arr.length; i++)
if (arr[i] != key)
arr[index++] = arr[i];
@tofuninjah
tofuninjah / mysql-db-utf
Last active December 17, 2018 16:03
MySQL CREATE Database with UTF-8
--
-- SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';
--
--
-- SHOW VARIABLES LIKE 'collation%';
--
CREATE DATABASE IF NOT EXISTS `hb_student_tracker`;