Skip to content

Instantly share code, notes, and snippets.

View h-hub's full-sized avatar
🤖
implementing something

Harsha Jayamanna h-hub

🤖
implementing something
View GitHub Profile
FROM ubuntu:latest
RUN apt-get install -y language-pack-ja-base language-pack-ja
update-locale LANG=ja_JP.UTF-8 LANGUAGE=”ja_JP:ja”
# for Java
ENV JAVA_HOME /usr/lib/jvm/java-8-oracle
RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \
apt-get update && \
package javaPractice.thread;
class MultiThread {
public static void main(String args[]) {
new MyThread("One");
new MyThread("Two");
new MyThread("Three");
try {
Thread.sleep(10000);
@h-hub
h-hub / FuturesB.java
Created December 1, 2018 06:30 — forked from benjchristensen/FuturesB.java
FuturesB.java Example of using Futures for nested calls showing how it blocks inefficiently.
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@h-hub
h-hub / FuturesA.java
Created December 1, 2018 06:31 — forked from benjchristensen/FuturesA.java
FuturesA.java Simple example of using Futures.
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class FuturesA {
public static void run() throws Exception {
public class ObservablesRun {
public static void main(String[] args) {
List<String> symbols = Arrays.asList("GOOG", "AAPL", "MSFT", "INTC");
Observable<StockInfo> feed = StockServer.getFeeed(symbols);
Disposable subscribe = feed.subscribeWith(new DisposableObserver<StockInfo>() {
int count = 0;
package javaPractice.jdbc;
//Import required packages
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class JdbcExample {
@Controller
public class BlogController {
private static final String BLOG_IMAGES = "blogImages";
private static final String TOMCAT_HOME_PROPERTY = "catalina.home";
private static final String TOMCAT_HOME_PATH = System.getProperty(TOMCAT_HOME_PROPERTY);
private static final String BLOG_IMAGES_PATH = TOMCAT_HOME_PATH + File.separator + BLOG_IMAGES;
private static final File BLOG_IMAGES_DIR = new File(BLOG_IMAGES_PATH);
private static final String BLOG_IMAGES_DIR_ABSOLUTE_PATH = BLOG_IMAGES_DIR.getAbsolutePath() + File.separator;
@Service
public class BlogPostServiceImpl implements BlogPostService {
@Autowired
private UserService userService;
@Autowired
private BlogPostRepository blogPostRepository;
@Autowired
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Bean
public ConfigurableServletWebServerFactory webServerFactory() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
tomcat.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> {
// configure maxSwallowSize
@Target({TYPE,ANNOTATION_TYPE})
@Retention(RUNTIME)
@Constraint(validatedBy = ContentTypeMultipartFileValidator.class)
@Documented
public @interface ContentType {
String message() default "Please upload jpg, png or gif and less than 5MB in size";
Class<?>[] groups() default {};